Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-11-03 17:54:56
Exec Total Coverage
Lines: 8533 12528 68.1%
Functions: 93 128 72.7%
Branches: 5698 10645 53.5%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/util.h"
3 #include "base/zapp.h"
4 #include "base/qrs.h"
5 #include "base/cpool.h"
6 #include "base/autocombo.h"
7 #include "base/packfile.h"
8 #include "base/dmap.h"
9 #include "base/combo.h"
10 #include "base/msgstr.h"
11 #include <filesystem>
12 #include <stdio.h>
13 #include <cstring>
14 #include <string>
15 #include <map>
16 #include <vector>
17 #include <assert.h>
18 #include <fmt/format.h>
19
20
21 #include "metadata/sigs/devsig.h.sig"
22 #include "metadata/sigs/compilersig.h.sig"
23 #include "metadata/versionsig.h"
24 #include "base/zc_alleg.h"
25 #include "base/zdefs.h"
26 #include "base/colors.h"
27 #include "tiles.h"
28 #include "base/zsys.h"
29 #include "qst.h"
30 #include "defdata.h"
31 #include "subscr.h"
32 #include "zc/replay.h"
33 #include "zc/zc_custom.h"
34 #include "sfx.h"
35 #include "md5.h"
36 #include "zinfo.h"
37 #include "zc/ffscript.h"
38 #include "particles.h"
39 #include "dialog/alert.h"
40 #include "base/misctypes.h"
41 #include "base/initdata.h"
42
43 //FFScript FFCore;
44 extern FFScript FFCore;
45 extern ZModule zcm;
46 extern zcmodule moduledata;
47 extern uint8_t __isZQuest;
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern particle_list particles;
50 extern void setZScriptVersion(int32_t s_version);
51 //FFSCript FFEngine;
52
53 static bool read_ext_zinfo = false, read_zinfo = false;
54 static bool loadquest_report = false;
55 static char const* loading_qst_name = NULL;
56 static byte loading_qst_num = 0;
57 static byte subscr_mode = ssdtMAX;
58 dword loading_tileset_flags = 0;
59
60 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
61 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
62
63 #ifdef _MSC_VER
64 #define strncasecmp _strnicmp
65 #endif
66
67 #ifndef _AL_MALLOC
68 #define _AL_MALLOC(a) _al_malloc(a)
69 #define _AL_FREE(a) _al_free(a)
70 #endif
71
72 using std::string;
73 using std::pair;
74
75 // extern bool debug;
76 extern int32_t hero_animation_speed; //lower is faster animation
77 extern byte *colordata;
78 //extern byte *tilebuf;
79 extern tiledata *newtilebuf;
80 extern byte *trashbuf;
81 extern itemdata *itemsbuf;
82 extern wpndata *wpnsbuf;
83 extern comboclass *combo_class_buf;
84 extern guydata *guysbuf;
85 extern ZCHEATS zcheats;
86 extern char palnames[MAXLEVELS][17];
87 extern int32_t memrequested;
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 116 std::map<int32_t, script_slot_data > ffcmap;
92 116 std::map<int32_t, script_slot_data > globalmap;
93 116 std::map<int32_t, script_slot_data > genericmap;
94 116 std::map<int32_t, script_slot_data > itemmap;
95 116 std::map<int32_t, script_slot_data > npcmap;
96 116 std::map<int32_t, script_slot_data > ewpnmap;
97 116 std::map<int32_t, script_slot_data > lwpnmap;
98 116 std::map<int32_t, script_slot_data > playermap;
99 116 std::map<int32_t, script_slot_data > dmapmap;
100 116 std::map<int32_t, script_slot_data > screenmap;
101 116 std::map<int32_t, script_slot_data > itemspritemap;
102 116 std::map<int32_t, script_slot_data > comboscriptmap;
103 116 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
111 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
112 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
113 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
114
115 char qstdat_string[2048] = { 0 };
116
117 static zinfo* load_tmp_zi = NULL;
118
119 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
120 const byte clavio[9]={97,109,111,110,103,117,115,0};
121
122 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
123 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
124
125 const char *qst_error[] =
126 {
127 "OK","File not found","Invalid quest file",
128 "Version not supported","Obsolete version",
129 "Missing new data" , /* but let it pass in ZQuest */
130 "Internal error occurred", "Invalid password",
131 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
132 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
133 };
134
135 //for legacy quests -DD
136 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
137 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
138 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
139 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
140 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
141 };
142
143 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
144
145
146 void delete_combo_aliases()
147 {
148 for(int32_t j(0); j<256; j++)
149 {
150 if(combo_aliases[j].combos != NULL)
151 {
152 delete[] combo_aliases[j].combos;
153 combo_aliases[j].combos=NULL;
154 }
155
156 if(combo_aliases[j].csets != NULL)
157 {
158 delete[] combo_aliases[j].csets;
159 combo_aliases[j].csets=NULL;
160 }
161 }
162
163 }
164
165 char *byte_conversion(int32_t number, int32_t format)
166 {
167 static char num_str[40];
168
169 if(format==-1) //auto
170 {
171 format=1; //bytes
172
173 if(number>1024)
174 {
175 format=2; //kilobytes
176 }
177
178 if(number>1024*1024)
179 {
180 format=3; //megabytes
181 }
182
183 if(number>1024*1024*1024)
184 {
185 format=4; //gigabytes (dude, what are you doing?)
186 }
187 }
188
189 switch(format)
190 {
191 case 1: //bytes
192 sprintf(num_str,"%db",number);
193 break;
194
195 case 2: //kilobytes
196 sprintf(num_str,"%.2fk",float(number)/1024);
197 break;
198
199 case 3: //megabytes
200 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
201 break;
202
203 case 4: //gigabytes
204 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
205 break;
206
207 default:
208 abort();
209 break;
210 }
211
212 return num_str;
213 }
214
215 1392 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
216 {
217 static char num_str1[40];
218 static char num_str2[40];
219 static char num_str[80];
220
221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1392 times.
1392 if(format1==-1) //auto
222 {
223 1392 format1=1; //bytes
224
225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1392 times.
1392 if(number1>1024)
226 {
227 1392 format1=2; //kilobytes
228 1392 }
229
230
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 464 times.
1392 if(number1>1024*1024)
231 {
232 464 format1=3; //megabytes
233 464 }
234
235
1/2
✓ Branch 0 taken 1392 times.
✗ Branch 1 not taken.
1392 if(number1>1024*1024*1024)
236 {
237 format1=4; //gigabytes (dude, what are you doing?)
238 }
239 1392 }
240
241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1392 times.
1392 if(format2==-1) //auto
242 {
243 1392 format2=1; //bytes
244
245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1392 times.
1392 if(number2>1024)
246 {
247 1392 format2=2; //kilobytes
248 1392 }
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1392 times.
1392 if(number2>1024*1024)
251 {
252 1392 format2=3; //megabytes
253 1392 }
254
255
1/2
✓ Branch 0 taken 1392 times.
✗ Branch 1 not taken.
1392 if(number2>1024*1024*1024)
256 {
257 format2=4; //gigabytes (dude, what are you doing?)
258 }
259 1392 }
260
261
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 928 times.
✓ Branch 3 taken 464 times.
✗ Branch 4 not taken.
1392 switch(format1)
262 {
263 case 1: //bytes
264 sprintf(num_str1,"%db",number1);
265 break;
266
267 case 2: //kilobytes
268 928 sprintf(num_str1,"%.2fk",float(number1)/1024);
269 928 break;
270
271 case 3: //megabytes
272 464 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
273 464 break;
274
275 case 4: //gigabytes
276 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
277 break;
278
279 default:
280 abort();
281 break;
282 }
283
284
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1392 times.
✗ Branch 4 not taken.
1392 switch(format2)
285 {
286 case 1: //bytes
287 sprintf(num_str2,"%db",number2);
288 break;
289
290 case 2: //kilobytes
291 sprintf(num_str2,"%.2fk",float(number2)/1024);
292 break;
293
294 case 3: //megabytes
295 1392 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
296 1392 break;
297
298 case 4: //gigabytes
299 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
300 break;
301
302 default:
303 abort();
304 break;
305 }
306
307 1392 sprintf(num_str, "%s/%s", num_str1, num_str2);
308 1392 return num_str;
309 }
310
311 char *ordinal(int32_t num)
312 {
313 static const char *ending[4] = {"st","nd","rd","th"};
314 static char ord_str[8];
315
316 char *end;
317 int32_t t=(num%100)/10;
318 int32_t n=num%10;
319
320 if(n>=1 && n<4 && t!=1)
321 end = (char *)ending[n-1];
322 else
323 end = (char *)ending[3];
324
325 sprintf(ord_str,"%d%s",num%10000,end);
326 return ord_str;
327 }
328
329 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
330 {
331 int32_t ret;
332 *version=0;
333 *build=0;
334 byte temp_map_count=map_count;
335 byte temp_midi_flags[MIDIFLAGS_SIZE];
336 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
337
338 zquestheader tempheader;
339
340 if(!f)
341 {
342 return qe_invalid;
343 }
344
345 ret=readheader(f, &tempheader);
346
347 if(ret)
348 {
349 return ret;
350 }
351
352 map_count=temp_map_count;
353 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
354 *version=tempheader.zelda_version;
355 *build=tempheader.build;
356 return 0;
357 }
358
359
360 bool find_section(PACKFILE *f, int32_t section_id_requested)
361 {
362
363 if(!f)
364 {
365 return false;
366 }
367
368 int32_t section_id_read;
369 bool catchup=false;
370 word dummy;
371 byte tempbyte;
372 char tempbuf[65536];
373
374
375 switch(section_id_requested)
376 {
377 case ID_RULES:
378 case ID_STRINGS:
379 case ID_MISC:
380 case ID_TILES:
381 case ID_COMBOS:
382 case ID_CSETS:
383 case ID_MAPS:
384 case ID_DMAPS:
385 case ID_DOORS:
386 case ID_ITEMS:
387 case ID_WEAPONS:
388 case ID_COLORS:
389 case ID_ICONS:
390 case ID_INITDATA:
391 case ID_GUYS:
392 case ID_MIDIS:
393 case ID_CHEATS:
394 break;
395
396 default:
397 al_trace("Bad section requested!\n");
398 return false;
399 break;
400 }
401
402 dword section_size;
403
404 //section id
405 if(!p_mgetl(&section_id_read,f))
406 {
407 return false;
408 }
409
410 while(!pack_feof(f))
411 {
412 switch(section_id_read)
413 {
414 case ID_RULES:
415 case ID_STRINGS:
416 case ID_MISC:
417 case ID_TILES:
418 case ID_COMBOS:
419 case ID_CSETS:
420 case ID_MAPS:
421 case ID_DMAPS:
422 case ID_DOORS:
423 case ID_ITEMS:
424 case ID_WEAPONS:
425 case ID_COLORS:
426 case ID_ICONS:
427 case ID_INITDATA:
428 case ID_GUYS:
429 case ID_MIDIS:
430 case ID_CHEATS:
431 catchup=false;
432 break;
433
434 default:
435 break;
436 }
437
438
439 while(catchup)
440 {
441 //section id
442 section_id_read=(section_id_read<<8);
443
444 if(!p_getc(&tempbyte,f))
445 {
446 return false;
447 }
448
449 section_id_read+=tempbyte;
450 }
451
452 if(section_id_read==section_id_requested)
453 {
454 return true;
455 }
456 else
457 {
458 //section version info
459 if(!p_igetw(&dummy,f))
460 {
461 return false;
462 }
463
464 if(!p_igetw(&dummy,f))
465 {
466 return false;
467 }
468
469 //section size
470 if(!p_igetl(&section_size,f))
471 {
472 return false;
473 }
474
475 //pack_fseek(f, section_size);
476 while(section_size>65535)
477 {
478 pfread(tempbuf,65535,f);
479 tempbuf[65535]=0;
480 section_size-=65535;
481 }
482
483 if(section_size>0)
484 {
485 pfread(tempbuf,section_size,f);
486 tempbuf[section_size]=0;
487 }
488 }
489
490 //section id
491 if(!p_mgetl(&section_id_read,f))
492 {
493 return false;
494 }
495 }
496
497 return false;
498 }
499
500
501
502
503
504 bool valid_zqt(PACKFILE *f)
505 {
506
507 //word tiles_used;
508 //word combos_used;
509 //open the file
510 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
511 if(!f)
512 return false;
513
514 //for now, everything else is valid
515 return true;
516
517 /*int16_t version;
518 byte build;
519
520 //read the version and make sure it worked
521 if(!p_igetw(&version,f))
522 {
523 goto error;
524 }
525
526 //read the build and make sure it worked
527 if(!p_getc(&build,f))
528 goto error;
529
530 //read the tile info and make sure it worked
531 if(!p_igetw(&tiles_used,f))
532 {
533 goto error;
534 }
535
536 for (int32_t i=0; i<tiles_used; i++)
537 {
538 if(!pfread(trashbuf,tilesize(tf4Bit),f))
539 {
540 goto error;
541 }
542 }
543
544 //read the combo info and make sure it worked
545 if(!p_igetw(&combos_used,f))
546 {
547 goto error;
548 }
549 for (int32_t i=0; i<combos_used; i++)
550 {
551 if(!pfread(trashbuf,sizeof(newcombo),f))
552 {
553 goto error;
554 }
555 }
556
557 //read the palette info and make sure it worked
558 for (int32_t i=0; i<48; i++)
559 {
560 if(!pfread(trashbuf,newpdTOTAL,f))
561 {
562 goto error;
563 }
564 }
565 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
566 {
567 goto error;
568 }
569 for (int32_t i=0; i<MAXLEVELS; i++)
570 {
571 if(!pfread(trashbuf,PALNAMESIZE,f))
572 {
573 goto error;
574 }
575 }
576
577 //read the sprite info and make sure it worked
578 for (int32_t i=0; i<MAXITEMS; i++)
579 {
580 if(!pfread(trashbuf,sizeof(itemdata),f))
581 {
582 goto error;
583 }
584 }
585
586 for (int32_t i=0; i<MAXWPNS; i++)
587 {
588 if(!pfread(trashbuf,sizeof(wpndata),f))
589 {
590 goto error;
591 }
592 }
593
594 //read the triforce pieces info and make sure it worked
595 for (int32_t i=0; i<8; ++i)
596 {
597 if(!p_getc(&trashbuf,f))
598 {
599 goto error;
600 }
601 }
602
603
604
605 //read the game icons info and make sure it worked
606 for (int32_t i=0; i<4; ++i)
607 {
608 if(!p_igetw(&trashbuf,f))
609 {
610 goto error;
611 }
612 }
613
614 //read the misc colors info and map styles info and make sure it worked
615 if(!pfread(trashbuf,sizeof(zcolors),f))
616 {
617 goto error;
618 }
619
620 //read the template screens and make sure it worked
621 byte num_maps;
622 if(!p_getc(&num_maps,f))
623 {
624 goto error;
625 }
626 for (int32_t i=0; i<TEMPLATES; i++)
627 {
628 if(!pfread(trashbuf,sizeof(mapscr),f))
629 {
630 goto error;
631 }
632 }
633 if (num_maps>1) //dungeon templates
634 {
635 for (int32_t i=0; i<TEMPLATES; i++)
636 {
637 if(!pfread(trashbuf,sizeof(mapscr),f))
638 {
639 goto error;
640 }
641 }
642 }
643
644 //yay! it worked! close the file and say everything was ok.
645 pack_fclose(f);
646 return true;
647
648 error:
649 pack_fclose(f);
650 return false;*/
651 }
652
653 bool valid_zqt(const char *filename)
654 {
655 PACKFILE *f=NULL;
656 bool isvalid;
657 int32_t error;
658 f=open_quest_file(&error, filename, false);
659
660 if(!f)
661 {
662 // setPackfilePassword(NULL);
663 return false;
664 }
665
666 isvalid=valid_zqt(f);
667
668 clear_quest_tmpfile();
669 pack_fclose(f);
670
671 // setPackfilePassword(NULL);
672 return isvalid;
673 }
674
675 /*
676 .qst file history
677
678 .qst files have always been compressed using allegro's packfiles.
679
680 At some point, an encoding layer was added. The two layers look like this:
681
682 1) The top layer is from us. See decode_file_007.
683 [0-24] Preamble "Zelda Classic Quest File"
684 [25-28] Initial decoding seed value.
685 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
686 [last 4] Checksum
687
688 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
689 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
690 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
691 The oldest quests skip the password part.
692
693 Simply, the job of this function is to peel away the top layer.
694
695 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
696 in opening and saving files. There is no version field, so they decryption key is
697 found via trial-by-error (very slow!)
698
699 There are other file types of interest:
700 - .zqt: quest template files, skips top-layer encryption pass
701 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
702 - .qu?: same as above. automated backup files
703 - .qb?: same as above. automated backup files
704 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
705
706 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
707 files are now "slh!.AG ZC Enhanced Quest File".
708 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
709 */
710 130 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
711 {
712
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (show_progress)
713 {
714 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
715 }
716
717 130 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
718
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 3 times.
130 if (unencrypted_result.decoded_pf)
719 127 return unencrypted_result.decoded_pf;
720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (unencrypted_result.not_found)
721 {
722 *open_error = qe_notfound;
723 return nullptr;
724 }
725
726 // Everything below here is legacy code - recently saved quest files will have
727 // returned by now.
728 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
729
730 // Note: although this is primarily for loading .qst files, it can also handle all of the
731 // file types mentioned in the comment above. No need to be told if the file being loaded
732 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
733 3 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
734 3 bool compressed = unencrypted_result.compressed;
735 3 bool encrypted = unencrypted_result.encrypted;
736
737 char tmpfilename[L_tmpnam];
738 3 temp_name(tmpfilename);
739 char percent_done[30];
740 3 int32_t current_method=0;
741
742 PACKFILE *f;
743 3 const char *passwd= encrypted ? datapwd : "";
744
745 // oldquest flag is set when an unencrypted qst file is suspected.
746 3 bool oldquest = false;
747 int32_t ret;
748
749
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
750 {
751 3 box_out(filename);
752 3 }
753 else
754 {
755 box_out("new quest"); // Or whatever
756 }
757 3 box_out("...");
758 3 box_eol();
759 3 box_eol();
760
761
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
762 {
763 3 box_out("Decrypting...");
764 3 box_save_x();
765 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
766
767
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
768 {
769 switch(ret)
770 {
771 case 1:
772 box_out("error.");
773 box_eol();
774 box_end(true);
775 *open_error=qe_notfound;
776 return NULL;
777
778 case 2:
779 box_out("error.");
780 box_eol();
781 box_end(true);
782 *open_error=qe_internal;
783 return NULL;
784 // be sure not to delete tmpfilename now...
785 }
786
787 if(ret==5) //old encryption?
788 {
789 current_method++;
790 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
791 box_out(percent_done);
792 box_load_x();
793 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
794 }
795
796 if(ret==5) //old encryption?
797 {
798 current_method++;
799 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
800 box_out(percent_done);
801 box_load_x();
802 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
803 }
804
805 if(ret==5) //old encryption?
806 {
807 current_method++;
808 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
809 box_out(percent_done);
810 box_load_x();
811 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
812 }
813
814 if(ret==5) //old encryption?
815 {
816 current_method++;
817 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
818 box_out(percent_done);
819 box_load_x();
820 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
821 }
822
823 if(ret)
824 {
825 oldquest = true;
826 passwd="";
827 }
828 }
829
830 3 box_out("okay.");
831 3 box_eol();
832 3 }
833 else
834 {
835 oldquest = true;
836 }
837
838 3 box_out("Opening...");
839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
840
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
841 {
842 if((compressed==1)&&(errno==EDOM))
843 {
844 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
845 }
846
847 if(!f)
848 {
849 if(!oldquest)
850 {
851 delete_file(tmpfilename);
852 }
853 box_out("error.");
854 box_eol();
855 box_end(true);
856 *open_error=qe_invalid;
857 return NULL;
858 }
859 }
860
861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
862 {
863 3 delete_file(tmpfilename);
864 3 }
865
866 3 box_out("okay.");
867 3 box_eol();
868
869 3 return f;
870 130 }
871
872 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
873 {
874 char *filename;
875 PACKFILE *f=NULL;
876 int32_t open_error=0;
877
878 strcpy(qstdat_string, "modules/classic/default.qst");
879 if(Header->templatepath[0]==0)
880 {
881 filename=(char *)malloc(2048);
882 strcpy(filename, qstdat_string);
883 }
884 else
885 {
886 // TODO: should be safe to remove this, no one seems to use custom quest templates.
887 filename=Header->templatepath;
888 }
889
890 f=open_quest_file(&open_error, filename, false);
891
892 if(Header->templatepath[0]==0)
893 {
894 free(filename);
895 }
896
897 if(!f)
898 {
899 return NULL;
900 }
901
902 if(validate)
903 {
904 if(!valid_zqt(f))
905 {
906 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
907 pack_fclose(f);
908 clear_quest_tmpfile();
909 return NULL;
910 }
911 }
912
913 return f;
914 }
915
916 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
917 {
918 // We absolutely do not support loading from a template file to initialize data outside the editor.
919 // TODO: move this code into zq/
920 if (get_app_id() != App::zquest) return false;
921
922 combosread=false;
923 mapsread=false;
924 fixffcs=false;
925
926 switch(section_id)
927 {
928 case ID_RULES:
929 case ID_STRINGS:
930 case ID_MISC:
931 case ID_TILES:
932 case ID_COMBOS:
933 case ID_CSETS:
934 case ID_MAPS:
935 case ID_DMAPS:
936 case ID_DOORS:
937 case ID_ITEMS:
938 case ID_WEAPONS:
939 case ID_COLORS:
940 case ID_ICONS:
941 case ID_INITDATA:
942 case ID_GUYS:
943 case ID_MIDIS:
944 case ID_CHEATS:
945 case ID_ITEMDROPSETS:
946 case ID_FAVORITES:
947 break;
948
949 default:
950 return false;
951 break;
952 }
953
954 int32_t ret;
955 word version, build;
956 PACKFILE *f=NULL;
957
958 char deletefilename[1024];
959 deletefilename[0]=0;
960
961 //why is this here?
962 /*
963 if(colordata==NULL)
964 return false;
965 */
966
967 //setPackfilePassword(datapwd);
968 f=open_quest_template(Header, deletefilename, validate);
969
970 if(!f) //no file, nothing to delete
971 {
972 // setPackfilePassword(NULL);
973 return false;
974 }
975
976 ret=get_version_and_build(f, &version, &build);
977
978 if(ret||(version==0))
979 {
980 pack_fclose(f);
981 clear_quest_tmpfile();
982
983 if(deletefilename[0])
984 {
985 delete_file(deletefilename);
986 }
987
988 // setPackfilePassword(NULL);
989 return false;
990 }
991
992 if(!find_section(f, section_id))
993 {
994 al_trace("Can't find section!\n");
995 pack_fclose(f);
996 clear_quest_tmpfile();
997
998 if(deletefilename[0])
999 {
1000 delete_file(deletefilename);
1001 }
1002
1003 //setPackfilePassword(NULL);
1004 return false;
1005 }
1006
1007 switch(section_id)
1008 {
1009 case ID_RULES:
1010 //rules
1011 ret=readrules(f, Header);
1012 break;
1013
1014 case ID_STRINGS:
1015 //strings
1016 ret=readstrings(f, Header);
1017 break;
1018
1019 case ID_MISC:
1020 //misc data
1021 ret=readmisc(f, Header, Misc);
1022 break;
1023
1024 case ID_TILES:
1025 //tiles
1026 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1027 break;
1028
1029 case ID_COMBOS:
1030 //combos
1031 clear_combos();
1032 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1033 combosread=true;
1034 break;
1035
1036 case ID_COMBOALIASES:
1037 //combos
1038 ret=readcomboaliases(f, Header, version, build);
1039 break;
1040
1041 case ID_CSETS:
1042 //color data
1043 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1044 break;
1045
1046 case ID_MAPS:
1047 //maps
1048 ret=readmaps(f, Header);
1049 mapsread=true;
1050 break;
1051
1052 case ID_DMAPS:
1053 //dmaps
1054 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1055 break;
1056
1057 case ID_DOORS:
1058 //door combo sets
1059 ret=readdoorcombosets(f, Header);
1060 break;
1061
1062 case ID_ITEMS:
1063 //items
1064 ret=readitems(f, version, build);
1065 break;
1066
1067 case ID_WEAPONS:
1068 //weapons
1069 ret=readweapons(f, Header);
1070 break;
1071
1072 case ID_COLORS:
1073 //misc. colors
1074 ret=readmisccolors(f, Header, Misc);
1075 break;
1076
1077 case ID_ICONS:
1078 //game icons
1079 ret=readgameicons(f, Header, Misc);
1080 break;
1081
1082 case ID_INITDATA:
1083 //initialization data
1084 ret=readinitdata(f, Header);
1085 break;
1086
1087 case ID_GUYS:
1088 //guys
1089 ret=readguys(f, Header);
1090 break;
1091
1092 case ID_MIDIS:
1093 //midis
1094 ret=readtunes(f, Header, tunes);
1095 break;
1096
1097 case ID_CHEATS:
1098 //cheat codes
1099 ret=readcheatcodes(f, Header);
1100 break;
1101
1102 case ID_ITEMDROPSETS:
1103 //item drop sets
1104 // Why is this one commented out?
1105 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1106 break;
1107
1108 case ID_FAVORITES:
1109 // favorite combos and aliases
1110 ret=readfavorites(f, version, build);
1111 break;
1112
1113 default:
1114 ret=-1;
1115 break;
1116 }
1117
1118 pack_fclose(f);
1119 clear_quest_tmpfile();
1120
1121 if(deletefilename[0])
1122 {
1123 delete_file(deletefilename);
1124 }
1125
1126 //setPackfilePassword(NULL);
1127 if(!ret)
1128 {
1129 return true;
1130 }
1131
1132 return false;
1133 }
1134
1135 bool init_tiles(bool validate, zquestheader *Header)
1136 {
1137 return init_section(Header, ID_TILES, NULL, NULL, validate);
1138 }
1139
1140 bool init_combos(bool validate, zquestheader *Header)
1141 {
1142 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1143 }
1144
1145 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1146 {
1147 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1148 }
1149
1150 130 void init_spritelists()
1151 {
1152
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
130 if(FFCore.quest_format[vZelda] < 0x255)
1153 {
1154 93 guys.setMax(255);
1155 93 items.setMax(255);
1156 93 Ewpns.setMax(255);
1157 93 Lwpns.setMax(255);
1158 93 chainlinks.setMax(255);
1159 93 decorations.setMax(255);
1160 93 particles.setMax(255);
1161 93 }
1162 else
1163 {
1164 37 guys.setMax(255);
1165 37 items.setMax(255);
1166 37 Ewpns.setMax(255);
1167 37 Lwpns.setMax(255);
1168 37 chainlinks.setMax(255);
1169 37 decorations.setMax(255);
1170 37 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1171 }
1172 130 }
1173
1174 116 bool reset_items(bool validate, zquestheader *Header)
1175 {
1176 116 bool ret = true;
1177
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (get_app_id() == App::zquest)
1178 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1179
1180
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29696 times.
29812 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1181
1182 116 return ret;
1183 }
1184
1185 bool reset_guys()
1186 {
1187 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1188 init_guys(V_GUYS);
1189 return true;
1190 }
1191
1192 bool reset_wpns(bool validate, zquestheader *Header)
1193 {
1194 bool ret = true;
1195 if (get_app_id() == App::zquest)
1196 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1197
1198 for(int32_t i=0; i<MAXWPNS; i++)
1199 reset_weaponname(i);
1200
1201 return ret;
1202 }
1203
1204 bool reset_mapstyles(bool validate, miscQdata *Misc)
1205 {
1206 Misc->colors.blueframe_tile = 20044;
1207 Misc->colors.blueframe_cset = 0;
1208 Misc->colors.triforce_tile = 23461;
1209 Misc->colors.triforce_cset = 1;
1210 Misc->colors.triframe_tile = 18752;
1211 Misc->colors.triframe_cset = 1;
1212 Misc->colors.overworld_map_tile = 16990;
1213 Misc->colors.overworld_map_cset = 2;
1214 Misc->colors.HCpieces_tile = 21160;
1215 Misc->colors.HCpieces_cset = 8;
1216 Misc->colors.dungeon_map_tile = 19651;
1217 Misc->colors.dungeon_map_cset = 8;
1218 return true;
1219 }
1220
1221 116 int32_t get_qst_buffers()
1222 {
1223 116 memrequested+=(sizeof(mapscr)*MAPSCRS);
1224 116 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1225 116 TheMaps.resize(MAPSCRS);
1226 116 map_autolayers.resize(6);
1227
1228
2/2
✓ Branch 0 taken 15776 times.
✓ Branch 1 taken 116 times.
15892 for(int32_t i(0); i<MAPSCRS; i++)
1229 15776 TheMaps[i].zero_memory();
1230
1231 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1232 116 Z_message("OK\n");
1233
1234 // Allocating space for all 65535 strings uses up 10.62MB...
1235 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1236 // (Shoelace's "Hero of Dreams" uses 1415.)
1237 // So let's be a bit generous and allow 4096 initially.
1238 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1239 // I tested it and it worked without flaw on 6/6/11. - L.
1240 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1241 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1242 // See https://discord.com/channels/876899628556091432/992984989073416242
1243 116 msg_strings_size = 8192;
1244 116 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1245 116 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1246
1247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 MsgStrings = new MsgStr[msg_strings_size];
1248
1249 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1250
2/2
✓ Branch 0 taken 950272 times.
✓ Branch 1 taken 116 times.
950388 for(auto q = 0; q < msg_strings_size; ++q)
1251 {
1252 950272 MsgStrings[q].clear();
1253 950272 }
1254 116 Z_message("OK\n"); // Allocating string buffer...
1255
1256 116 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1257 116 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1258
1259
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1260 return 0;
1261
1262 116 Z_message("OK\n"); // Allocating door combo buffer...
1263
1264 116 memrequested+=(sizeof(dmap)*MAXDMAPS);
1265 116 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1266
1267
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((DMaps=new dmap[MAXDMAPS])==NULL)
1268 return 0;
1269
1270 116 Z_message("OK\n"); // Allocating dmap buffer...
1271
1272 116 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1273 116 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1274
1275 116 combobuf.clear();
1276 116 combobuf.resize(MAXCOMBOS);
1277 116 Z_message("OK\n"); // Allocating combo buffer...
1278
1279 116 memrequested+=(psTOTAL255);
1280 116 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1281
1282
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1283 return 0;
1284
1285 116 Z_message("OK\n"); // Allocating color data buffer...
1286
1287 116 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1288 116 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1289
1290 116 free_newtilebuf();
1291
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1292 return 0;
1293
1294 116 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1295 //Z_message("Performed memset on tiles\n");
1296 116 clear_tiles(newtilebuf);
1297 //Z_message("Performed clear_tiles()\n");
1298 116 Z_message("OK\n"); // Allocating tile buffer...
1299
1300
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(is_editor())
1301 {
1302 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1303 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1304
1305 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1306 return 0;
1307
1308 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1309 clear_tiles(grabtilebuf);
1310 Z_message("OK\n"); // Allocating tile grab buffer...
1311 }
1312
1313 116 memrequested+=(100000);
1314 116 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1315
1316
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((trashbuf=(byte*)malloc(100000))==NULL)
1317 return 0;
1318
1319 116 Z_message("OK\n"); // Allocating trash buffer...
1320
1321 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1322 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1323 // fixed by ensuring there's actually itemdata there.
1324 // If you change this, be sure to update del_qst_buffers, too.
1325
1326 116 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1327 116 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1328
1329
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1330 return 0;
1331
1332 116 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1333 116 itemsbuf++;
1334 116 Z_message("OK\n"); // Allocating item buffer...
1335
1336 116 memrequested+=(sizeof(wpndata)*MAXWPNS);
1337 116 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1338
1339
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1340 return 0;
1341
1342 116 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1343 116 Z_message("OK\n"); // Allocating weapon buffer...
1344
1345 116 memrequested+=(sizeof(guydata)*MAXGUYS);
1346 116 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1347
1348
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1349 return 0;
1350
1351 116 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1352 116 Z_message("OK\n"); // Allocating guy buffer...
1353
1354 116 memrequested+=(sizeof(comboclass)*cMAX);
1355 116 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1356
1357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1358 return 0;
1359
1360 116 Z_message("OK\n"); // Allocating combo class buffer...
1361
1362 116 return 1;
1363 116 }
1364
1365
1366 116 void free_newtilebuf()
1367 {
1368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(newtilebuf)
1369 {
1370 for(int32_t i=0; i<NEWMAXTILES; i++)
1371 if(newtilebuf[i].data)
1372 free(newtilebuf[i].data);
1373
1374 free(newtilebuf);
1375 newtilebuf = 0;
1376 }
1377 116 }
1378
1379 void free_grabtilebuf()
1380 {
1381 if(is_editor())
1382 {
1383 if(grabtilebuf)
1384 {
1385 for(int32_t i=0; i<NEWMAXTILES; i++)
1386 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1387
1388 free(grabtilebuf);
1389 grabtilebuf = 0;
1390 }
1391 }
1392 }
1393
1394 void del_qst_buffers()
1395 {
1396 if(MsgStrings) delete[] MsgStrings;
1397
1398 if(DoorComboSets) free(DoorComboSets);
1399
1400 if (DMaps) delete[] DMaps;
1401
1402 combobuf.clear();
1403
1404 if(colordata) free(colordata);
1405
1406 free_newtilebuf();
1407 free_grabtilebuf();
1408
1409 if(trashbuf) free(trashbuf);
1410
1411 // See get_qst_buffers
1412 if(itemsbuf)
1413 {
1414 itemsbuf--;
1415 free(itemsbuf);
1416 }
1417
1418 if(wpnsbuf) free(wpnsbuf);
1419
1420 if(guysbuf) free(guysbuf);
1421
1422 if(combo_class_buf) free(combo_class_buf);
1423 }
1424
1425 4 bool init_palnames()
1426 {
1427 // if(palnames==NULL)
1428 // return false;
1429
1430
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1431 {
1432
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1433 {
1434 case 0:
1435 4 sprintf(palnames[x],"Overworld");
1436 4 break;
1437
1438 case 10:
1439 4 sprintf(palnames[x],"Caves");
1440 4 break;
1441
1442 case 11:
1443 4 sprintf(palnames[x],"Passageways");
1444 4 break;
1445
1446 default:
1447 2036 sprintf(palnames[x],"%c",0);
1448 2036 break;
1449 }
1450 2048 }
1451
1452 4 return true;
1453 }
1454
1455 25134 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1456 {
1457 void *p;
1458
1459
1/2
✓ Branch 0 taken 25134 times.
✗ Branch 1 not taken.
25134 p = _AL_MALLOC(MAX(size, alloc_size));
1460
1461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25134 times.
25134 if(!p)
1462 {
1463 return NULL;
1464 }
1465
1466
1/2
✓ Branch 0 taken 25134 times.
✗ Branch 1 not taken.
25134 if(!pfread(p,size,f))
1467 {
1468 _AL_FREE(p);
1469 return NULL;
1470 }
1471
1472
1/2
✓ Branch 0 taken 25134 times.
✗ Branch 1 not taken.
25134 if(pack_ferror(f))
1473 {
1474 _AL_FREE(p);
1475 return NULL;
1476 }
1477
1478 25134 return p;
1479 25134 }
1480
1481 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1482 static const byte* legacy_skip_flags;
1483
1484 /* read_midi:
1485 * Reads MIDI data from a datafile (this is not the same thing as the
1486 * standard midi file format).
1487 */
1488
1489 2295 static MIDI *read_midi(PACKFILE *f)
1490 {
1491 MIDI *m;
1492 int32_t c;
1493 2295 int16_t divisions=0;
1494 2295 int32_t len=0;
1495
1496 2295 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1497
1498
1/2
✓ Branch 0 taken 2295 times.
✗ Branch 1 not taken.
2295 if(!m)
1499 {
1500 return NULL;
1501 }
1502
1503
2/2
✓ Branch 0 taken 73440 times.
✓ Branch 1 taken 2295 times.
75735 for(c=0; c<MIDI_TRACKS; c++)
1504 {
1505 73440 m->track[c].len = 0;
1506 73440 m->track[c].data = NULL;
1507 73440 }
1508
1509 2295 p_mgetw(&divisions,f);
1510 2295 m->divisions=divisions;
1511
1512
2/2
✓ Branch 0 taken 73440 times.
✓ Branch 1 taken 2295 times.
75735 for(c=0; c<MIDI_TRACKS; c++)
1513 {
1514 73440 p_mgetl(&len,f);
1515 73440 m->track[c].len=len;
1516
1517
2/2
✓ Branch 0 taken 48306 times.
✓ Branch 1 taken 25134 times.
73440 if(m->track[c].len > 0)
1518 {
1519 25134 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1520
1521
1/2
✓ Branch 0 taken 25134 times.
✗ Branch 1 not taken.
25134 if(!m->track[c].data)
1522 {
1523 destroy_midi(m);
1524 return NULL;
1525 }
1526 25134 }
1527 73440 }
1528
1529 LOCK_DATA(m, sizeof(MIDI));
1530
1531
2/2
✓ Branch 0 taken 73440 times.
✓ Branch 1 taken 2295 times.
75735 for(c=0; c<MIDI_TRACKS; c++)
1532 {
1533
2/2
✓ Branch 0 taken 25134 times.
✓ Branch 1 taken 48306 times.
73440 if(m->track[c].data)
1534 {
1535 LOCK_DATA(m->track[c].data, m->track[c].len);
1536 25134 }
1537 73440 }
1538
1539 2295 return m;
1540 2295 }
1541
1542 void clear_combo(int32_t i)
1543 {
1544 combobuf[i].clear();
1545 }
1546
1547 void clear_combos()
1548 {
1549 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1550 clear_combo(tmpcounter);
1551 }
1552
1553 void pack_combos()
1554 {
1555 int32_t di = 0;
1556
1557 for(int32_t si=0; si<1024; si+=2)
1558 combobuf[di++] = combobuf[si];
1559
1560 for(; di<1024; di++)
1561 clear_combo(di);
1562 }
1563
1564 130 void reset_tunes(zctune *tune)
1565 {
1566
2/2
✓ Branch 0 taken 32760 times.
✓ Branch 1 taken 130 times.
32890 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1567 {
1568 32760 tune[i].reset();
1569 32760 }
1570 130 }
1571
1572
1573 /*void reset_midi(zcmidi_ *m)
1574 {
1575 m->title[0]=0;
1576 m->loop=1;
1577 m->volume=144;
1578 m->start=0;
1579 m->loop_start=-1;
1580 m->loop_end=-1;
1581 if(m->midi)
1582 {
1583 destroy_midi(m->midi);
1584 }
1585 m->midi=NULL;
1586 }
1587
1588
1589 void reset_midis(zcmidi_ *m)
1590 {
1591 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1592 {
1593 reset_midi(m+i);
1594 }
1595 }
1596 */
1597
1598 void reset_scr(int32_t scr)
1599 {
1600 /*
1601 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1602 for(unsigned i=0; i<sizeof(mapscr); i++)
1603 *(di++) = 0;
1604 TheMaps[scr].valid=mVERSION;
1605 */
1606
1607 TheMaps[scr].zero_memory();
1608 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1609
1610 for(int32_t i=0; i<6; i++)
1611 {
1612 //these will be uncommented later
1613 //TheMaps[scr].layerxsize[i]=16;
1614 //TheMaps[scr].layerysize[i]=11;
1615 TheMaps[scr].layeropacity[i]=255;
1616 }
1617
1618 TheMaps[scr].valid=mVERSION;
1619
1620 }
1621
1622 /* For reference:
1623
1624 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1625 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1626 */
1627
1628 3574 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1629 {
1630
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 1606 times.
18028 for(int32_t i=0; i<9; i++)
1631 {
1632
2/2
✓ Branch 0 taken 88692 times.
✓ Branch 1 taken 14454 times.
103146 for(int32_t j=0; j<6; j++)
1633 {
1634
2/2
✓ Branch 0 taken 28908 times.
✓ Branch 1 taken 59784 times.
88692 if(j<4)
1635 {
1636
2/2
✓ Branch 0 taken 57816 times.
✓ Branch 1 taken 1968 times.
59784 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1637 {
1638 1968 return false;
1639 }
1640
1641
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1642 {
1643 return false;
1644 }
1645
1646
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1647 {
1648 return false;
1649 }
1650
1651
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1652 {
1653 return false;
1654 }
1655 57816 }
1656
1657
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1658 {
1659 return false;
1660 }
1661
1662
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1663 {
1664 return false;
1665 }
1666
1667
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1668 {
1669 return false;
1670 }
1671
1672
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1673 {
1674 return false;
1675 }
1676 86724 }
1677
1678
2/2
✓ Branch 0 taken 11242 times.
✓ Branch 1 taken 3212 times.
14454 if(i<2)
1679 {
1680
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.flags[i]!=b.flags[i])
1681 {
1682 return false;
1683 }
1684
1685
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1686 {
1687 return false;
1688 }
1689
1690
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1691 {
1692 return false;
1693 }
1694
1695
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1696 {
1697 return false;
1698 }
1699
1700
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1701 {
1702 return false;
1703 }
1704 3212 }
1705
1706
2/2
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 4818 times.
14454 if(i<3)
1707 {
1708
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1709 {
1710 return false;
1711 }
1712
1713
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1714 {
1715 return false;
1716 }
1717
1718
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1719 {
1720 return false;
1721 }
1722
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4818 times.
4818 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1724 {
1725 return false;
1726 }
1727 4818 }
1728
1729
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1730 {
1731 return false;
1732 }
1733
1734
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1735 {
1736 return false;
1737 }
1738 14454 }
1739
1740 1606 return true;
1741 3574 }
1742
1743 int32_t doortranslations_u[9][4]=
1744 {
1745 {37,38,53,54},
1746 {37,38,39,40},
1747 {37,38,55,56},
1748 {37,38,39,40},
1749 {37,38,53,54},
1750 {37,38,53,54},
1751 {37,38,53,54},
1752 {7,8,23,24},
1753 {7,8,41,42}
1754 };
1755
1756 int32_t doortranslations_d[9][4]=
1757 {
1758 {117,118,133,134},
1759 {135,136,133,134},
1760 {119,120,133,134},
1761 {135,136,133,134},
1762 {117,118,133,134},
1763 {117,118,133,134},
1764 {117,118,133,134},
1765 {151,152,167,168},
1766 {137,138,167,168},
1767 };
1768
1769 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1770 int32_t doortranslations_l[9][6]=
1771 {
1772 {66,67,82,83,98,99},
1773 {66,68,82,84,98,100},
1774 {66,69,82,85,98,101},
1775 {66,68,82,84,98,100},
1776 {66,67,82,83,98,99},
1777 {66,67,82,83,98,99},
1778 {66,67,82,83,98,99},
1779 {64,65,80,81,96,97},
1780 {64,65,80,114,96,97},
1781 };
1782
1783 int32_t doortranslations_r[9][6]=
1784 {
1785
1786 {76,77,92,93,108,109},
1787 {75,77,91,93,107,109},
1788 {74,77,90,93,106,109},
1789 {75,77,91,93,107,109},
1790 {76,77,92,93,108,109},
1791 {76,77,92,93,108,109},
1792 {76,77,92,93,108,109},
1793 {78,79,94,95,110,111},
1794 {78,79,125,95,110,111},
1795 };
1796
1797 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1798 {
1799 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1800 }
1801
1802 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1803 {
1804 //these are here to bypass compiler warnings about unused arguments
1805 308180 map=map;
1806 308180 scr=scr;
1807 308180 pos=pos;
1808
1809 //what does this function do?
1810 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1811 308180 return 2;
1812 }
1813
1814 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1815 {
1816
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1817 {
1818 5450 return 0;
1819 }
1820
1821 DoorComboSet tempdcs;
1822 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1823
1824 //up
1825
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1826 {
1827
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1828 {
1829 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1830 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1831 58392 }
1832 14598 }
1833
1834 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1835 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1836 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1837 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1838 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1839 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1840
1841 //down
1842
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1843 {
1844
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1845 {
1846 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1847 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1848 58392 }
1849 14598 }
1850
1851 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1852
1853 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1854 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1855 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1856 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1857 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1858
1859 //left
1860 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1861
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1862 {
1863
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1864 {
1865 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1866 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1867 87588 }
1868 14598 }
1869
1870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1871 {
1872 if((j!=2)&&(j!=3))
1873 {
1874 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1875 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1876 }
1877 }
1878
1879 1622 tempdcs.bombdoorcombo_l[0]=0;
1880 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1881 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1882 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1883 1622 tempdcs.bombdoorcombo_l[2]=0;
1884 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1885 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1886 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1887
1888 //right
1889
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1890 {
1891
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1892 {
1893 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1894 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1895 87588 }
1896 14598 }
1897
1898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1899 {
1900 if((j!=2)&&(j!=3))
1901 {
1902 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1903 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1904 }
1905 }
1906
1907 1622 tempdcs.bombdoorcombo_r[0]=0;
1908 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1909 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1910 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1911 1622 tempdcs.bombdoorcombo_r[2]=0;
1912 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1913 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1914 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1915
1916 int32_t k;
1917
1918
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 3574 times.
3590 for(k=0; k<door_combo_set_count; k++)
1919 {
1920
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 1968 times.
3574 if(DoorComboSets[k]==tempdcs)
1921 {
1922 1606 break;
1923 }
1924 1968 }
1925
1926
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 16 times.
1622 if(k==door_combo_set_count)
1927 {
1928 16 DoorComboSets[k]=tempdcs;
1929 16 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1930 16 ++door_combo_set_count;
1931 16 }
1932
1933 1622 return k;
1934 /*
1935 doorcombo_u[9][4];
1936 doorcset_u[9][4];
1937 doorcombo_d[9][4];
1938 doorcset_d[9][4];
1939 doorcombo_l[9][6];
1940 doorcset_l[9][6];
1941 doorcombo_r[9][6];
1942 doorcset_r[9][6];
1943 bombdoorcombo_u[2];
1944 bombdoorcset_u[2];
1945 bombdoorcombo_d[2];
1946 bombdoorcset_d[2];
1947 bombdoorcombo_l[3];
1948 bombdoorcset_l[3];
1949 bombdoorcombo_r[3];
1950 bombdoorcset_r[3];
1951 walkthroughcombo[4];
1952 walkthroughcset[4];
1953 */
1954 7072 }
1955
1956 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1957 {
1958 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1959 }
1960
1961 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1962 {
1963
1964 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1965 }
1966
1967 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1968 {
1969 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1970 }
1971
1972
1973 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1974 {
1975 char temp_pwd[30];
1976 16 memset(temp_pwd,0,30);
1977
1978
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
1979 {
1980 16 memcpy(temp_pwd,encrypted_pwd,30);
1981 16 temp_pwd[29]=0;
1982
1983
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
1984 {
1985 480 temp_pwd[i] -= pwdkey;
1986 480 int32_t t=pwdkey>>15;
1987 480 pwdkey = (pwdkey<<1)+t;
1988 480 }
1989 16 }
1990
1991 16 memcpy(pwd,temp_pwd,30);
1992 16 }
1993
1994
1995 92 bool devpwd()
1996 {
1997 #ifdef _DEBUG
1998 return true;
1999 #endif
2000
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
2001 }
2002 bool check_questpwd(zquestheader *Header, char *pwd)
2003 {
2004 #if DEVLEVEL > 3
2005 return true;
2006 #endif
2007
2008 if (devpwd()) return true;
2009 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2010 cvs_MD5Context ctx;
2011 uint8_t md5sum[16];
2012
2013 cvs_MD5Init(&ctx);
2014 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2015 cvs_MD5Final(md5sum, &ctx);
2016
2017 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2018 }
2019
2020 122 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2021 {
2022 122 zprint2("\n");
2023 122 zprint2("[QUEST METADATA]\n");
2024
1/2
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
122 if(qst_num < moduledata.max_quest_files)
2025 zprint2("Loading module quest %d\n", qst_num+1);
2026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
122 if(path) zprint2("Loading '%s'\n", path);
2027
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 4 times.
122 if ( tempheader.new_version_id_main > 0 )
2028 {
2029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(tempheader.new_version_id_fourth > 0)
2030 zprint2("Last saved in version %d.%d.%d.%d ",
2031 tempheader.new_version_id_main,tempheader.new_version_id_second,
2032 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2033 118 else zprint2("Last saved in version: %d.%d.%d ",
2034 118 tempheader.new_version_id_main,tempheader.new_version_id_second,
2035 118 tempheader.new_version_id_third);
2036 118 }
2037 else
2038 {
2039
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2040 {
2041 case 0x255:
2042 {
2043 zprint2("Last saved in version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2044 break;
2045 }
2046 case 0x254:
2047 {
2048 zprint2("Last saved in version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2049 break;
2050 }
2051 case 0x250:
2052 {
2053 switch(tempheader.build)
2054 {
2055 case 19:
2056 zprint2("Last saved in version: 2.50.0, Gamma 1"); break;
2057 case 20:
2058 zprint2("Last saved in version: 2.50.0, Gamma 2"); break;
2059 case 21:
2060 zprint2("Last saved in version: 2.50.0, Gamma 3"); break;
2061 case 22:
2062 zprint2("Last saved in version: 2.50.0, Gamma 4"); break;
2063 case 23:
2064 zprint2("Last saved in version: 2.50.0, Gamma 5"); break;
2065 case 24:
2066 zprint2("Last saved in version: 2.50.0, Release"); break;
2067 case 25:
2068 zprint2("Last saved in version: 2.50.1, Gamma 1"); break;
2069 case 26:
2070 zprint2("Last saved in version: 2.50.1, Gamma 2"); break;
2071 case 27:
2072 zprint2("Last saved in version: 2.50.1, Gamma 3"); break;
2073 case 28:
2074 zprint2("Last saved in version: 2.50.1, Release"); break;
2075 case 29:
2076 zprint2("Last saved in version: 2.50.2, Release"); break;
2077 case 30:
2078 zprint2("Last saved in version: 2.50.3, Gamma 1"); break;
2079 case 31:
2080 zprint2("Last saved in version: 2.53.0, Prior to Gamma 3"); break;
2081 case 32:
2082 zprint2("Last saved in version: 2.53.0"); break;
2083 case 33:
2084 zprint2("Last saved in version: 2.53.1"); break;
2085 default:
2086 zprint2("Last saved in version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2087
2088 }
2089 break;
2090 }
2091
2092 case 0x211:
2093 {
2094 zprint2("Last saved in version: 2.11, Beta %d", tempheader.build); break;
2095 }
2096 case 0x210:
2097 {
2098 zprint2("Last saved in version: 2.10.x");
2099 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2100 break;
2101 }
2102 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2103 case 0x193:
2104 {
2105 zprint2("Last saved in version: 1.93, Beta %d\n", tempheader.build); break;
2106 }
2107 case 0x192:
2108 {
2109 zprint2("Last saved in version: 1.92, Beta %d\n", tempheader.build); break;
2110 }
2111 case 0x190:
2112 {
2113 zprint2("Last saved in version: 1.90, Beta/Build %d\n", tempheader.build); break;
2114 }
2115 case 0x184:
2116 {
2117 zprint2("Last saved in version: 1.84, Beta/Build %d\n", tempheader.build); break;
2118 }
2119 case 0x183:
2120 {
2121 zprint2("Last saved in version: 1.83, Beta/Build %d\n", tempheader.build); break;
2122 }
2123 case 0x180:
2124 {
2125 zprint2("Last saved in version: 1.80, Beta/Build %d\n", tempheader.build); break;
2126 }
2127 default:
2128 {
2129 zprint2("Last saved in version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2130 }
2131 */
2132 }
2133 }
2134
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
122 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2135 29 zprint2("%s\n", tempheader.getAlphaVerStr());
2136 93 else zprint2("\n");
2137
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2138
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2139
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2140
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2141
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 118 times.
122 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2142
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 29 times.
122 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2143 122 zprint2("\n");
2144 122 }
2145
2146 130 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2147 {
2148 int32_t dummy;
2149 zquestheader tempheader;
2150 char dummybuf[80];
2151 byte temp_map_count;
2152 byte temp_midi_flags[MIDIFLAGS_SIZE];
2153 word version;
2154 char temp_pwd[30], temp_pwd2[30];
2155 int16_t temp_pwdkey;
2156 cvs_MD5Context ctx;
2157 130 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2158 130 memset(&tempheader, 0, sizeof(tempheader));
2159 130 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2160
2161
2162
2163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2164 {
2165 Z_message("Unable to read header string\n");
2166 return qe_invalid;
2167 }
2168
2169 // check header
2170
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2171 {
2172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2173 {
2174 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2175 return qe_invalid;
2176 }
2177 4 }
2178
2179 130 int32_t templatepath_len=0;
2180
2181 130 tempheader.external_zinfo = false;
2182 130 read_zinfo = false;
2183
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2184 {
2185 byte padding;
2186
2187
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2188 {
2189 return qe_invalid;
2190 }
2191
2192
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2193 {
2194 return qe_invalid;
2195 }
2196
2197 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2198
2199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2200 {
2201 return qe_version;
2202 }
2203
2204 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2205
2206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2207 {
2208 return qe_invalid;
2209 }
2210
2211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2212 {
2213 return qe_obsolete;
2214 }
2215
2216
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2217 {
2218 return qe_invalid;
2219 }
2220
2221
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2222 {
2223 return qe_invalid;
2224 }
2225
2226 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2227
2228
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2229 {
2230 return qe_invalid;
2231 }
2232
2233
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2234 {
2235 return qe_invalid;
2236 }
2237
2238 4 FFCore.quest_format[qMapCount] = temp_map_count;
2239
2240
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2241 {
2242 return qe_invalid;
2243 }
2244
2245
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2246 {
2247 return qe_invalid;
2248 }
2249
2250
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2251 {
2252 return qe_invalid;
2253 }
2254
2255
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2256 {
2257 return qe_invalid;
2258 }
2259
2260
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2261 {
2262 return qe_invalid;
2263 }
2264
2265
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2266 {
2267 return qe_invalid;
2268 }
2269
2270
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2271 {
2272 return qe_invalid;
2273 }
2274
2275
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2276 {
2277 return qe_invalid;
2278 }
2279
2280
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2281 {
2282 return qe_invalid;
2283 }
2284 // These fields are expected to end in null bytes!
2285 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2286
2287
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2288 {
2289 return qe_invalid;
2290 }
2291 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2292
2293
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2294 {
2295 return qe_invalid;
2296 }
2297
2298
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2299 {
2300 return qe_invalid;
2301 }
2302
2303
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2304 {
2305 return qe_invalid;
2306 }
2307
2308 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2309 4 cvs_MD5Init(&ctx);
2310 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2311 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2312
2313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2314 {
2315 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2316 // Not anymore...
2317 memset(tempheader.minver,0,17);
2318 tempheader.build=0;
2319 tempheader.use_keyfile=0;
2320 memset(tempheader.old_foo, 0, 9);
2321 }
2322 else
2323 {
2324
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2325 {
2326 return qe_invalid;
2327 }
2328
2329
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2330 {
2331 return qe_invalid;
2332 }
2333
2334 4 FFCore.quest_format[vBuild] = tempheader.build;
2335
2336
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2337 {
2338 return qe_invalid;
2339 }
2340
2341
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2342 {
2343 return qe_invalid;
2344 }
2345 } // starting at minver
2346
2347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2348 {
2349 memset(&quest_rules[4],0,16); // word rules3..rules10
2350 }
2351 else
2352 {
2353
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2354 {
2355 return qe_invalid; // starting at rules3
2356 }
2357
2358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2359 {
2360 4 set_qr(qr_MEANPLACEDTRAPS,0);
2361 4 }
2362 }
2363 4 unpack_qrs();
2364
2365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2366 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2367 {
2368 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2369 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2370 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2371 4 }
2372
2373
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2374 {
2375 byte *mf=temp_midi_flags;
2376
2377 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2378 {
2379 mf=(byte*)dummybuf;
2380 }
2381
2382 if(!pfread(mf,32,f)) // read new header additions
2383 {
2384 return qe_invalid; // starting at foo2
2385 }
2386
2387 if(!pfread(dummybuf,18,f)) // read new header additions
2388 {
2389 return qe_invalid; // starting at foo2
2390 }
2391 }
2392
2393
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2394 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2395 {
2396 4 memset(tempheader.templatepath,0,2048);
2397 4 }
2398 else
2399 {
2400 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2401 {
2402 return qe_invalid;
2403 }
2404 }
2405
2406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2407 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2408 {
2409 4 tempheader.use_keyfile=0;
2410 4 }
2411 4 }
2412 else
2413 {
2414 //section id
2415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!p_mgetl(&dummy,f))
2416 {
2417 return qe_invalid;
2418 }
2419
2420 //section version info
2421
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&version,f))
2422 {
2423 return qe_invalid;
2424 }
2425
2426 126 FFCore.quest_format[vHeader] = version;
2427
2428
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy,f))
2429 {
2430 return qe_invalid;
2431 }
2432
2433 //section size
2434
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
2435 {
2436 return qe_invalid;
2437 }
2438
2439 //finally... section data
2440
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&tempheader.zelda_version,f))
2441 {
2442 return qe_invalid;
2443 }
2444
2445 126 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2446
2447 //do some quick checking...
2448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(tempheader.zelda_version > ZELDA_VERSION)
2449 {
2450 return qe_version;
2451 }
2452
2453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2454 {
2455 return qe_invalid;
2456 }
2457
2458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(bad_version(tempheader.zelda_version))
2459 {
2460 return qe_obsolete;
2461 }
2462
2463
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.build,f))
2464 {
2465 return qe_invalid;
2466 }
2467
2468 126 FFCore.quest_format[vBuild] = tempheader.build;
2469
2470
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
126 if(version<3)
2471 {
2472
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2473 {
2474 return qe_invalid;
2475 }
2476
2477
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2478 {
2479 return qe_invalid;
2480 }
2481
2482 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2483 12 cvs_MD5Init(&ctx);
2484 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2485 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2486 12 }
2487 else
2488 {
2489
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2490 {
2491 return qe_invalid;
2492 }
2493 }
2494
2495
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&tempheader.internal,f))
2496 {
2497 return qe_invalid;
2498 }
2499
2500
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.quest_number,f))
2501 {
2502 return qe_invalid;
2503 }
2504
2505 126 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2506
2507 126 size_t versz = version < 8 ? 9 : 16;
2508
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.version,versz,f))
2509 {
2510 return qe_invalid;
2511 }
2512
2513 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2514 //needs to be copied as char[9] or stored as a s.str
2515
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.minver,versz,f))
2516 {
2517 return qe_invalid;
2518 }
2519
2520 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2521
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2522 {
2523 return qe_invalid;
2524 }
2525 126 tempheader.title[sizeof(tempheader.title)-1] = 0;
2526
2527
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2528 {
2529 return qe_invalid;
2530 }
2531 126 tempheader.author[sizeof(tempheader.author)-1] = 0;
2532
2533
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.use_keyfile,f))
2534 {
2535 return qe_invalid;
2536 }
2537
2538 /*
2539 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2540 {
2541 return qe_invalid;
2542 }
2543 */
2544
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2545 {
2546 return qe_invalid;
2547 }
2548
2549
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(&dummybuf,4,f))
2550 {
2551 return qe_invalid;
2552 }
2553
2554
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2555 {
2556 return qe_invalid;
2557 }
2558
2559
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(dummybuf,14,f))
2560 {
2561 return qe_invalid;
2562 }
2563
2564 126 templatepath_len=sizeof(tempheader.templatepath);
2565
2566
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 if(version==1)
2567 {
2568 12 templatepath_len=280;
2569 12 }
2570
2571
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(tempheader.templatepath,templatepath_len,f))
2572 {
2573 return qe_invalid;
2574 }
2575
2576
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_getc(&temp_map_count,f))
2577 {
2578 return qe_invalid;
2579 }
2580
2581
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(version>=4)
2582 {
2583
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_main,f))
2584 {
2585 return qe_invalid;
2586 }
2587
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_second,f))
2588 {
2589 return qe_invalid;
2590 }
2591
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_third,f))
2592 {
2593 return qe_invalid;
2594 }
2595
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2596 {
2597 return qe_invalid;
2598 }
2599
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2600 {
2601 return qe_invalid;
2602 }
2603
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_beta,f))
2604 {
2605 return qe_invalid;
2606 }
2607
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2608 {
2609 return qe_invalid;
2610 }
2611
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.new_version_id_release,f))
2612 {
2613 return qe_invalid;
2614 }
2615
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2616 {
2617 return qe_invalid;
2618 }
2619
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.new_version_id_date_month,f))
2620 {
2621 return qe_invalid;
2622 }
2623
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.new_version_id_date_day,f))
2624 {
2625 return qe_invalid;
2626 }
2627
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2628 {
2629 return qe_invalid;
2630 }
2631
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2632 {
2633 return qe_invalid;
2634 }
2635
2636
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.new_version_devsig,256,f))
2637 {
2638 return qe_invalid;
2639 }
2640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2641 strcpy(tempheader.new_version_devsig, "EmilyV99");
2642
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.new_version_compilername,256,f))
2643 {
2644 return qe_invalid;
2645 }
2646
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.new_version_compilerversion,256,f))
2647 {
2648 return qe_invalid;
2649 }
2650
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.product_name,1024,f))
2651 {
2652 return qe_invalid;
2653 }
2654
2655
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&tempheader.compilerid,f))
2656 {
2657 return qe_invalid;
2658 }
2659
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2660 {
2661 return qe_invalid;
2662 }
2663
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2664 {
2665 return qe_invalid;
2666 }
2667
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2668 {
2669 return qe_invalid;
2670 }
2671
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2672 {
2673 return qe_invalid;
2674 }
2675
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetw(&tempheader.developerid,f))
2676 {
2677 return qe_invalid;
2678 }
2679
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.made_in_module_name,1024,f))
2680 {
2681 return qe_invalid;
2682 }
2683
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.build_datestamp,256,f))
2684 {
2685 return qe_invalid;
2686 }
2687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(!pfread(tempheader.build_timestamp,256,f))
2688 {
2689 return qe_invalid;
2690 }
2691 37 }
2692 else // <4
2693 {
2694 89 tempheader.new_version_id_main = 0;
2695 89 tempheader.new_version_id_second = 0;
2696 89 tempheader.new_version_id_third = 0;
2697 89 tempheader.new_version_id_fourth = 0;
2698 89 tempheader.new_version_id_alpha = 0;
2699 89 tempheader.new_version_id_beta = 0;
2700 89 tempheader.new_version_id_gamma = 0;
2701 89 tempheader.new_version_id_release = 0;
2702 89 tempheader.new_version_id_date_year = 0;
2703 89 tempheader.new_version_id_date_month = 0;
2704 89 tempheader.new_version_id_date_day = 0;
2705 89 tempheader.new_version_id_date_hour = 0;
2706 89 tempheader.new_version_id_date_minute = 0;
2707
2708 89 memset(tempheader.new_version_devsig, 0, 256);
2709 89 memset(tempheader.new_version_compilername, 0, 256);
2710 89 memset(tempheader.new_version_compilerversion, 0, 256);
2711 89 memset(tempheader.product_name, 0, 1024);
2712 89 strcpy(tempheader.product_name, "ZQuest Classic");
2713
2714 89 tempheader.compilerid = 0;
2715 89 tempheader.compilerversionnumber_first = 0;
2716 89 tempheader.compilerversionnumber_second = 0;
2717 89 tempheader.compilerversionnumber_third = 0;
2718 89 tempheader.compilerversionnumber_fourth = 0;
2719 89 tempheader.developerid = 0;
2720
2721 89 memset(tempheader.made_in_module_name, 0, 1024);
2722 89 memset(tempheader.build_datestamp, 0, 256);
2723 89 memset(tempheader.build_timestamp, 0, 256);
2724 }
2725
2726
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if ( version >= 5 )
2727 {
2728
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!pfread(tempheader.build_timezone,6,f))
2729 {
2730 return qe_invalid;
2731 }
2732 37 }
2733 else // < 5
2734 {
2735 89 memset(tempheader.build_timezone, 0, 6);
2736 }
2737
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if ( version >= 6 )
2738 {
2739 byte b;
2740
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&b,f))
2741 {
2742 return qe_invalid;
2743 }
2744 37 tempheader.external_zinfo = b?true:false;
2745 37 read_zinfo = true;
2746 37 }
2747
2748
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(version >= 7)
2749 {
2750
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2751 {
2752 return qe_invalid;
2753 }
2754 37 }
2755 else
2756 {
2757 89 tempheader.new_version_is_nightly = false;
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2759 {
2760
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2761 {
2762 case 0x254:
2763 tempheader.new_version_id_main = 2;
2764 tempheader.new_version_id_second = 54;
2765 break;
2766 case 0x250:
2767
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2768 {
2769 case 19:
2770 tempheader.new_version_id_main = 2;
2771 tempheader.new_version_id_second = 50;
2772 tempheader.new_version_id_gamma = 1;
2773 break;
2774 case 20:
2775 tempheader.new_version_id_main = 2;
2776 tempheader.new_version_id_second = 50;
2777 tempheader.new_version_id_gamma = 2;
2778 break;
2779 case 21:
2780 tempheader.new_version_id_main = 2;
2781 tempheader.new_version_id_second = 50;
2782 tempheader.new_version_id_gamma = 3;
2783 break;
2784 case 22:
2785 tempheader.new_version_id_main = 2;
2786 tempheader.new_version_id_second = 50;
2787 tempheader.new_version_id_gamma = 4;
2788 break;
2789 case 23:
2790 tempheader.new_version_id_main = 2;
2791 tempheader.new_version_id_second = 50;
2792 tempheader.new_version_id_gamma = 5;
2793 break;
2794 case 24:
2795 22 tempheader.new_version_id_main = 2;
2796 22 tempheader.new_version_id_second = 50;
2797 22 tempheader.new_version_id_release = -1;
2798 22 break;
2799 case 25:
2800 tempheader.new_version_id_main = 2;
2801 tempheader.new_version_id_second = 50;
2802 tempheader.new_version_id_third = 1;
2803 tempheader.new_version_id_gamma = 1;
2804 break;
2805 case 26:
2806 tempheader.new_version_id_main = 2;
2807 tempheader.new_version_id_second = 50;
2808 tempheader.new_version_id_third = 1;
2809 tempheader.new_version_id_gamma = 2;
2810 break;
2811 case 27:
2812 tempheader.new_version_id_main = 2;
2813 tempheader.new_version_id_second = 50;
2814 tempheader.new_version_id_third = 1;
2815 tempheader.new_version_id_gamma = 3;
2816 break;
2817 case 28:
2818 5 tempheader.new_version_id_main = 2;
2819 5 tempheader.new_version_id_second = 50;
2820 5 tempheader.new_version_id_third = 1;
2821 5 tempheader.new_version_id_release = -1;
2822 5 break;
2823 case 29:
2824 24 tempheader.new_version_id_main = 2;
2825 24 tempheader.new_version_id_second = 50;
2826 24 tempheader.new_version_id_third = 2;
2827 24 tempheader.new_version_id_release = -1;
2828 24 break;
2829 case 30:
2830 tempheader.new_version_id_main = 2;
2831 tempheader.new_version_id_second = 50;
2832 tempheader.new_version_id_third = 3;
2833 tempheader.new_version_id_gamma = 1;
2834 break;
2835 case 31:
2836 15 tempheader.new_version_id_main = 2;
2837 15 tempheader.new_version_id_second = 53;
2838 15 tempheader.new_version_id_gamma = -1;
2839 15 break;
2840 case 32:
2841 10 tempheader.new_version_id_main = 2;
2842 10 tempheader.new_version_id_second = 53;
2843 10 tempheader.new_version_id_release = -1;
2844 10 break;
2845 case 33:
2846 1 tempheader.new_version_id_main = 2;
2847 1 tempheader.new_version_id_second = 53;
2848 1 tempheader.new_version_id_third = 1;
2849 1 break;
2850 }
2851 77 break;
2852
2853 case 0x211:
2854 tempheader.new_version_id_main = 2;
2855 tempheader.new_version_id_second = 11;
2856 tempheader.new_version_id_beta = tempheader.build;
2857 break;
2858 case 0x210:
2859 12 tempheader.new_version_id_main = 2;
2860 12 tempheader.new_version_id_second = 10;
2861 12 tempheader.new_version_id_beta = tempheader.build;
2862 12 break;
2863 }
2864 89 }
2865 }
2866
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if(printmetadata || __isZQuest)
2867 {
2868 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2869 }
2870 }
2871
2872 //{ Version Warning
2873 130 int32_t vercmp = tempheader.compareVer();
2874 130 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2875 130 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2876
4/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
167 if(vercmp > 0 || (!vercmp &&
2877
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 (astatecmp > 0 || (!astatecmp &&
2878 37 avercmp > 0))))
2879 {
2880 bool r = true;
2881 if(loadquest_report)
2882 {
2883 enter_sys_pal();
2884 AlertDialog("Quest saved in newer version",
2885 "This quest was last saved in a newer version of ZQuest."
2886 " Attempting to load this quest may not work correctly; to"
2887 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2888 "\n\nWould you like to continue loading anyway? (Not recommended)",
2889 [&](bool ret,bool)
2890 {
2891 r = ret;
2892 }).show();
2893 exit_sys_pal();
2894 }
2895 if(!r)
2896 return qe_silenterr;
2897 }
2898
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 else if(tempheader.compareDate() > 0)
2899 {
2900 bool r = true;
2901 if(loadquest_report)
2902 {
2903 enter_sys_pal();
2904 AlertDialog("Quest saved in newer build",
2905 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2906 " issues loading in this build."
2907 "\n{}"
2908 "\n\nWould you like to continue loading anyway?",
2909 tempheader.getVerCmpStr()),
2910 [&](bool ret,bool)
2911 {
2912 r = ret;
2913 }).show();
2914 exit_sys_pal();
2915 }
2916 if(!r)
2917 return qe_silenterr;
2918 }
2919 //}
2920
2921 130 read_ext_zinfo = tempheader.external_zinfo;
2922
2923 130 memcpy(Header, &tempheader, sizeof(tempheader));
2924 130 map_count=temp_map_count;
2925 130 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2926
2927 130 unpack_qrs();
2928
2929 130 return 0;
2930 130 }
2931
2932 130 int32_t readrules(PACKFILE *f, zquestheader *Header)
2933 {
2934
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (should_skip)
2936 return 0;
2937
2938 int32_t dummy;
2939 zquestheader tempheader;
2940 130 word s_version=0;
2941 130 dword compatrule_version=0;
2942
2943 130 memcpy(&tempheader, Header, sizeof(tempheader));
2944
2945
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(tempheader.zelda_version >= 0x193)
2946 {
2947 //section version info
2948
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
2949 {
2950 return qe_invalid;
2951 }
2952
2953 126 FFCore.quest_format[vRules] = s_version;
2954
2955
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy,f))
2956 {
2957 return qe_invalid;
2958 }
2959
2960
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if(s_version > 16)
2961 {
2962
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&compatrule_version,f))
2963 {
2964 return qe_invalid;
2965 }
2966 37 }
2967 126 FFCore.quest_format[vCompatRule] = compatrule_version;
2968
2969 //section size
2970
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
2971 {
2972 return qe_invalid;
2973 }
2974
2975
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if ( s_version < 15 )
2976 {
2977 //finally... section data
2978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2979 {
2980 return qe_invalid;
2981 }
2982 89 }
2983 else
2984 {
2985
2986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2987 {
2988 return qe_invalid;
2989 }
2990
2991 }
2992 126 }
2993
2994 //al_trace("Rules version %d\n", s_version);
2995 //{ bunch of compat stuff
2996 130 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2997
2998 130 unpack_qrs();
2999
3000
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<2)
3001 {
3002 16 set_qr(14,0);
3003 16 set_qr(27,0);
3004 16 set_qr(28,0);
3005 16 set_qr(29,0);
3006 16 set_qr(30,0);
3007 16 set_qr(32,0);
3008 16 set_qr(36,0);
3009 16 set_qr(49,0);
3010 16 set_qr(50,0);
3011 16 set_qr(51,0);
3012 16 set_qr(68,0);
3013 16 set_qr(75,0);
3014 16 set_qr(76,0);
3015 16 set_qr(98,0);
3016 16 set_qr(110,0);
3017 16 set_qr(113,0);
3018 16 set_qr(116,0);
3019 16 set_qr(102,0);
3020 16 set_qr(132,0);
3021 16 }
3022
3023 //Now, do any updates...
3024
3/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3025 {
3026 16 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3027 16 set_qr(qr_REPLACEOPENDOORS, 1);
3028 16 set_qr(qr_OLDLENSORDER, 1);
3029 16 set_qr(qr_NOFAIRYGUYFIRES, 1);
3030 16 set_qr(qr_TRIGGERSREPEAT, 1);
3031 16 }
3032
3033
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3034 {
3035 4 set_qr(qr_WALLFLIERS,1);
3036 4 }
3037
3038
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3039 {
3040 4 set_qr(qr_NOBOMBPALFLASH,1);
3041 4 }
3042
3043
5/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
130 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3044 {
3045 6 set_qr(qr_NOSCROLLCONTINUE,1);
3046 6 }
3047
3048
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
132 if(tempheader.zelda_version <= 0x210)
3049 {
3050 16 set_qr(qr_ARROWCLIP,1);
3051 16 }
3052
3053
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 12 times.
128 if(tempheader.zelda_version == 0x210)
3054 {
3055 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3056 12 set_qr(qr_CMBCYCLELAYERS, 0);
3057 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3058 12 }
3059
3060
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(tempheader.zelda_version <= 0x210)
3061 {
3062 16 set_qr(qr_OLDSTYLEWARP,1);
3063 16 set_qr(qr_210_WARPRETURN,1);
3064 16 }
3065
3066 //might not be correct
3067
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4 times.
128 if(tempheader.zelda_version < 0x210)
3068 {
3069 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3070 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3071 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3072 4 }
3073
3074
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
128 if(tempheader.zelda_version < 0x211)
3075 {
3076 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3077 16 }
3078
3079
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 124 times.
128 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
3080 {
3081 4 set_qr(qr_192b163_WARP,1);
3082 4 }
3083
3084
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 12 times.
128 if(tempheader.zelda_version == 0x210)
3085 {
3086 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3087 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3088 12 set_qr(qr_DMGCOMBOPRI, 0);
3089 12 }
3090
3091
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
128 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3092 {
3093 16 set_qr(qr_OLDPICKUP,1);
3094 16 }
3095
3096
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
132 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3097 {
3098 16 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3099 16 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3100 16 }
3101
3102
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 16 times.
132 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3103 {
3104 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3105 16 }
3106
3107
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
128 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3108 {
3109 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3110 22 }
3111
3112
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 75 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3113 {
3114 16 set_qr(qr_OLD_DOORREPAIR, 1);
3115 16 }
3116
3117
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
128 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3118 {
3119 16 set_qr(qr_OLD_SECRETMONEY, 1);
3120 16 }
3121
3122
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
132 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3123 {
3124 38 set_qr(qr_OLD_POTION_OR_HC, 1);
3125 38 }
3126
3127
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
132 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3128 {
3129 38 set_qr(qr_OFFSCREENWEAPONS, 1);
3130 38 }
3131
3132 //Bombchu fix.
3133
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 77 times.
132 if(tempheader.zelda_version == 0x250)
3134 {
3135
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3136 {
3137 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3138 22 }
3139
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3140 {
3141 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3142 5 }
3143
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3144 {
3145 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3146 24 }
3147
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3148 {
3149 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3150 }
3151 77 }
3152
3153
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 52 times.
132 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3154 {
3155 // qr_OFFSETEWPNCOLLISIONFIX
3156 // All 'official' quests need this disabled.
3157 // All 2.10 and lower quests need this enabled to preseve compatability.
3158 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3159
3160 //~Gleeok
3161 43 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3162
3163 // Broke in build 695
3164
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
43 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3165 27 set_qr(qr_BROKENSTATUES, 1);
3166 43 }
3167
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 if (tempheader.zelda_version <= 0x190)
3168 {
3169 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3170 4 }
3171
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 37 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 37 times.
132 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3172 {
3173 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3174 94 }
3175
3176
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3177 {
3178 16 set_qr(qr_OLD_210_WATER, 1);
3179 16 }
3180
3181
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3182 {
3183 93 set_qr(qr_STEP_IS_FLOAT,0);
3184 93 }
3185
3186
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if ( tempheader.zelda_version < 0x250 )
3187 {
3188 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3189 16 }
3190
3191
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version < 3)
3192 {
3193 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3194 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3195 16 }
3196
3197
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<4)
3198 {
3199 16 set_qr(10,0);
3200 16 }
3201
3202
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<5)
3203 {
3204 16 set_qr(27,0);
3205 16 }
3206
3207
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<6)
3208 {
3209 16 set_qr(46,0);
3210 16 }
3211
3212
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<7) // January 2008
3213 {
3214 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3215 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3216 16 }
3217
3218
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 if(s_version<8)
3219 {
3220 16 set_qr(12, 0);
3221 16 }
3222 else
3223 {
3224 114 set_bit(deprecated_rules, 12, 0);
3225 }
3226
3227
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<9) // October 2008
3228 {
3229 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3230 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3231 16 set_qr(qr_GHINI2BLINK_DEP,0);
3232 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3233 16 }
3234
3235
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<10) // December 2008
3236 {
3237 16 set_qr(qr_NOCLOCKS_DEP,0);
3238 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3239 16 }
3240
3241
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<11) // April 2009
3242 {
3243 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3244 16 }
3245
3246 // This served no purpose.
3247 // if(s_version<12) // December 2009
3248 // {
3249 // set_qr(qr_BRKBLSHLDS_DEP,0);
3250 // set_qr(qr_OLDTRIBBLES_DEP,0);
3251 // }
3252
3253 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3254
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version < 13)
3255 {
3256 16 set_qr(qr_SHOPCHEAT, 1);
3257 16 }
3258
3259 // Not entirely sure this is the best place for this...
3260 //2.50.2 bitmap offset fix
3261 130 memset(extra_rules, 0, EXTRARULES_SIZE);
3262
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3263 {
3264 43 set_er(er_BITMAPOFFSET, 1);
3265 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3266 43 }
3267 //required because quest templates also used this bit, although
3268 //it never did anything, before. -Z
3269
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 77 times.
130 if ( tempheader.zelda_version == 0x250 )
3270 {
3271
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3272 {
3273 39 set_er(er_BITMAPOFFSET, 0);
3274 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3275 39 }
3276 77 }
3277
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if ( tempheader.zelda_version == 0x254 )
3278 {
3279 set_er(er_BITMAPOFFSET, 0);
3280 set_qr(qr_BITMAPOFFSETFIX, 0);
3281 }
3282
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
130 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3283 {
3284 set_er(er_BITMAPOFFSET, 0);
3285 set_qr(qr_BITMAPOFFSETFIX, 0);
3286 }
3287 //optimise fast drawing for older versions.
3288
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3289 {
3290 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3291 93 }
3292 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3293 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3294 //older quests can set the rule by hand. We need a new qst.dat again.
3295
4/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3296 {
3297 set_qr(qr_OLDEWPNPARENT, 1);
3298 }
3299
4/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3300 {
3301 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3302 }
3303
4/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3304 {
3305 set_qr(qr_OLDQUESTMISC, 1);
3306 }
3307
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if ( tempheader.zelda_version < 0x254 )
3308 {
3309 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3310 93 set_qr(qr_OLDEWPNPARENT, 0);
3311 93 set_qr(qr_OLDQUESTMISC, 0);
3312 93 }
3313
3314 //item scripts continue to run
3315
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3316 {
3317 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3318 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3319 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3320 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3321 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3322 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3323 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3324 93 }
3325
3326
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3327 {
3328 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3329 93 }
3330
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3331 {
3332 93 set_qr(qr_TRACESCRIPTIDS, 0);
3333 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3334 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3335 93 set_qr(qr_PARSER_250DIVISION,1);
3336 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3337 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3338 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3339 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3340
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3341 {
3342 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3343 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3344 //Now they **do**, unless you disable that behaviour.
3345 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3346 //now enable the disable L/R item swap on load.
3347 2 }
3348
3349 93 }
3350
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3351 {
3352 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3353 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3354 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3355 //animations ending earlier than they should.
3356 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3357 //Enemies would ignore solidity on the top half of combos
3358 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3359 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3360 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3361 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3362 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3363 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3364 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3365 93 }
3366
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if ( tempheader.zelda_version < 0x255 )
3367 {
3368 93 set_qr(qr_NOFFCWAITDRAW, 1);
3369 93 set_qr(qr_NOITEMWAITDRAW, 1);
3370 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3371 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3372 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3373 93 }
3374
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3375 {
3376 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3377 93 }
3378
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3379 {
3380 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3381 93 }
3382
3383
3384
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3385 {
3386 93 set_qr(qr_BROKEN_RING_POWER, 1);
3387 93 }
3388
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3389 {
3390 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3391 93 }
3392
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3393 {
3394 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3395 93 }
3396
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3397 {
3398 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3399
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3400 set_qr(qr_SET_YBUTTON_ITEMS,1);
3401 93 }
3402
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3403 {
3404 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3405 93 }
3406
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3407 {
3408 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3409 93 }
3410
3411
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if ( tempheader.zelda_version < 0x254 )
3412 {
3413 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3414 93 }
3415 //Sideview spikes in 2.50.0
3416
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3417 {
3418 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3419 38 }
3420 //more 2.50 fixes -Z
3421
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
130 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3422 {
3423 67 set_qr(qr_MELEEMAGICCOST, 0);
3424 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3425 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3426 67 set_qr(qr_BROKENBOOKCOST, 1);
3427 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3428
3429 67 }
3430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
130 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3431 {
3432 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3433 set_qr(qr_MELEEMAGICCOST, 1);
3434 }
3435
3436
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(tempheader.zelda_version < 0x193)
3437 {
3438 4 set_qr(qr_SHORTDGNWALK, 1);
3439 4 }
3440
3441
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(tempheader.zelda_version < 0x255)
3442 {
3443 93 set_qr(qr_OLDINFMAGIC, 1);
3444 93 }
3445
3446
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3447 {
3448 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3449 16 }
3450
3451
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3452 {
3453 93 set_qr(qr_OLD_F6,1);
3454 93 }
3455
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3456 {
3457 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3458 93 }
3459
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3460 {
3461 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3462 93 }
3463
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3464 {
3465 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3466 93 }
3467 //}
3468
3469
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3470 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3471
3472
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 2) //Old CSet2 Handling
3473 93 set_qr(qr_OLDCS2,1);
3474
3475
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3476 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3477
3478
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3479 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3480
3481
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
130 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3482 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3483
3484
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3485 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3486
3487
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3488 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3489
3490
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3491 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3492
3493
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 9)
3494 {
3495 //Hardcoded BS Patras
3496 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3497 //Hardcoded Patra Inner Eye offsets
3498 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3499 //Broken 'Big enemy' animation style
3500 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3501 //Broken Attribute 31/32
3502 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3503 93 }
3504
3505
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 10) //Shared candle use limits
3506 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3507
3508
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 11) //No cross-screen return points
3509 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3510
3511
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 12)
3512 {
3513 //Old fire trail duration
3514 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3515 //Old Intro String in Ganon Room Behavior
3516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3517 93 else set_qr(qr_GANONINTRO,1);
3518 93 }
3519
3520
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
130 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3521 set_qr(qr_ANONE_NOANIM,1);
3522
3523
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 14) //Old Bridge Combo Behavior
3524 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3525
3526
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 15) //Broken Z3 Animation
3527 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3528
3529
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3530 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3531
3532
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 17)
3533 {
3534 //Old Quake/DrawYOffset behavior
3535 //set_qr(qr_OLD_DRAWOFFSET,1);
3536 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3537 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3538 93 }
3539
3540
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 18)
3541 {
3542 //Broken DrawScreen Derivative Functions
3543 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3544 //Scrolling Cancels Charge
3545 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3546 93 }
3547
3548
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3549 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3550
3551
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 20)
3552 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3553
3554
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 21)
3555 {
3556 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3557 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3558 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3559 93 set_qr(qr_OLD_BUG_NET,1);
3560 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3561 93 }
3562
3563
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 22)
3564 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3565
3566
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 23)
3567 93 set_qr(qr_OLD_HALF_MAGIC,1);
3568
3569
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 24)
3570 {
3571 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3572 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3573 93 }
3574
3575
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 25)
3576 {
3577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3578 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3579 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3580 93 }
3581
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 26)
3582 {
3583 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3584 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3585 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3586 93 }
3587
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3588 {
3589
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3590 27993 set_qr(q,0);
3591
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 93 times.
279 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3592 186 set_qr(q,0);
3593 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3594 93 }
3595
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 28)
3596 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3597
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 29)
3598 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3599
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 30)
3600 {
3601 95 set_qr(qr_DECO_2_YOFFSET,1);
3602 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3603 95 }
3604
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 31)
3605 {
3606 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3607 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3608 95 }
3609
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 32)
3610 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3611
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 33)
3612 95 set_qr(qr_NO_LIFT_SPRITE,1);
3613
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 34)
3614 {
3615 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3616 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3617 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3618 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3619 95 }
3620
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 35)
3621 {
3622 95 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3623 95 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3624 95 }
3625
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(compatrule_version < 36)
3626 95 set_qr(qr_OLD_SHALLOW_SFX,1);
3627
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 97 times.
130 if(compatrule_version < 37)
3628 97 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3629
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 97 times.
130 if(compatrule_version < 38)
3630 97 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3631
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 97 times.
130 if(compatrule_version < 39)
3632 97 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3633
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 97 times.
130 if(compatrule_version < 40)
3634 97 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3635
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 41)
3636 98 set_qr(qr_BROKENHITBY,1);
3637
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 42)
3638 98 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3639
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 43)
3640 98 set_qr(qr_OLD_BOMB_HITBOXES,1);
3641
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 44)
3642 98 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3643
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 45)
3644 98 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3645
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 98 times.
130 if(compatrule_version < 46)
3646 98 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3647
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 47)
3648 {
3649 101 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3650 101 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3651 101 }
3652
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 48)
3653 101 set_qr(qr_OLD_GUY_HANDLING,1);
3654
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 49)
3655 101 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3656
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 50)
3657 101 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3658
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 51)
3659 101 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3660
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if (compatrule_version < 52)
3661 101 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3662
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 53)
3663 {
3664 101 set_qr(qr_OLD_SUBSCR,1);
3665 101 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3666 101 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3667 101 }
3668
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 54)
3669 101 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3670
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 55)
3671 101 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3672
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 56)
3673 101 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3674
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 57)
3675 101 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3676
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 58)
3677 101 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3678
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
130 if(compatrule_version < 59)
3679 101 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(compatrule_version < 60)
3681 130 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(compatrule_version < 61)
3683 130 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3684
3685 130 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3686
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if (s_version < 16)
3687 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3688
3689 130 memcpy(Header, &tempheader, sizeof(tempheader));
3690
3691 130 return 0;
3692 130 }
3693
3694 1091936 void init_msgstr(MsgStr *str)
3695 {
3696 1091936 str->s = "";
3697 1091936 str->s.shrink_to_fit();
3698 1091936 str->nextstring=0;
3699 1091936 str->tile=0;
3700 1091936 str->cset=0;
3701 1091936 str->trans=false;
3702 1091936 str->font=font_zfont;
3703 1091936 str->y=32;
3704 1091936 str->sfx=18;
3705 1091936 str->listpos=0;
3706 1091936 str->x=24;
3707 1091936 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3708 1091936 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3709 1091936 str->hspace=0;
3710 1091936 str->vspace=0;
3711 1091936 str->stringflags=0;
3712 1091936 str->margins[up] = 8;
3713 1091936 str->margins[down] = 0;
3714 1091936 str->margins[left] = 8;
3715 1091936 str->margins[right] = 0;
3716 1091936 str->portrait_tile = 0;
3717 1091936 str->portrait_cset = 0;
3718 1091936 str->portrait_x = 0;
3719 1091936 str->portrait_y = 0;
3720 1091936 str->portrait_tw = 1;
3721 1091936 str->portrait_th = 1;
3722 1091936 str->shadow_type = 0;
3723 1091936 str->shadow_color = 0;
3724 1091936 str->drawlayer = 6;
3725 1091936 }
3726
3727 130 void init_msgstrings(int32_t start, int32_t end)
3728 {
3729
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
130 if(end <= start || end-start > msg_strings_size)
3730 return;
3731
3732
2/2
✓ Branch 0 taken 1064960 times.
✓ Branch 1 taken 130 times.
1065090 for(int32_t i=start; i<end; i++)
3733 {
3734 1064960 init_msgstr(&MsgStrings[i]);
3735 1064960 MsgStrings[i].listpos=i;
3736 1064960 }
3737
3738
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(start==0)
3739 {
3740 130 MsgStrings[0].s = "(None)";
3741 130 MsgStrings[0].listpos = 0;
3742 130 }
3743 130 }
3744
3745 130 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3746 {
3747
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3748
3749 130 MsgStr tempMsgString;
3750
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 init_msgstr(&tempMsgString);
3751
3752 130 word temp_msg_count=0;
3753 word temp_expansion[16];
3754 130 memset(temp_expansion, 0, 16*sizeof(word));
3755 130 char buf[8193] = {0};
3756
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version < 0x193)
3757 {
3758 byte tempbyte;
3759 4 int32_t strings_to_read=0;
3760
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!should_skip)
3761
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3762
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3763 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3764 {
3765 4 strings_to_read=128;
3766 4 temp_msg_count=Header->old_str_count;
3767
3768 // Some sort of string count corruption seems to be common in old quests
3769
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3770 {
3771 temp_msg_count=128;
3772 }
3773 4 }
3774 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3775 {
3776 strings_to_read=255;
3777 temp_msg_count=Header->old_str_count;
3778 }
3779 else
3780 {
3781 if(!p_igetw(&temp_msg_count,f))
3782 {
3783 return qe_invalid;
3784 }
3785
3786 strings_to_read=temp_msg_count;
3787
3788 if (!should_skip && temp_msg_count >= msg_strings_size)
3789 {
3790 Z_message("Reallocating string buffer...\n");
3791
3792 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3793 // return qe_nomem;
3794
3795 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3796 delete[] MsgStrings;
3797 MsgStrings = new MsgStr[MAXMSGS];
3798 msg_strings_size = MAXMSGS;
3799 for(auto q = 0; q < msg_strings_size; ++q)
3800 {
3801 MsgStrings[q].clear();
3802 }
3803 }
3804 }
3805
3806 //reset the message strings
3807
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!should_skip)
3808
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3809
3810
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3811 {
3812
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3813 512 tempMsgString.listpos = x;
3814
3815
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3816 {
3817 return qe_invalid;
3818 }
3819
3820 512 buf[74] = '\0';
3821
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3822
3823
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3824 {
3825 return qe_invalid;
3826 }
3827
3828
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3829 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3830 {
3831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3832
3833
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3834 {
3835 return qe_invalid;
3836 }
3837
3838
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3839 {
3840 return qe_invalid;
3841 }
3842 512 }
3843 else
3844 {
3845 if(!p_igetw(&tempMsgString.nextstring,f))
3846 {
3847 return qe_invalid;
3848 }
3849
3850 if(!pfread(temp_expansion,32,f))
3851 {
3852 return qe_invalid;
3853 }
3854 }
3855
3856
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if (!should_skip)
3857
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3858 512 }
3859 4 }
3860 else
3861 {
3862 int32_t dummy_int;
3863 word s_version;
3864 word s_cversion;
3865
3866 //section version info
3867
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_version,f))
3868 {
3869 return qe_invalid;
3870 }
3871
3872 126 FFCore.quest_format[vStrings] = s_version;
3873
3874
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_cversion,f))
3875 {
3876 return qe_invalid;
3877 }
3878
3879 //al_trace("Strings version %d\n", s_version);
3880 //section size
3881
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetl(&dummy_int,f))
3882 {
3883 return qe_invalid;
3884 }
3885
3886 //finally... section data
3887
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&temp_msg_count,f))
3888 {
3889 return qe_invalid;
3890 }
3891
3892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(temp_msg_count >= msg_strings_size)
3893 {
3894 Z_message("Reallocating string buffer...\n");
3895
3896 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3897 // return qe_nomem;
3898 delete[] MsgStrings;
3899 MsgStrings = new MsgStr[MAXMSGS];
3900 msg_strings_size = MAXMSGS;
3901 for(auto q = 0; q < msg_strings_size; ++q)
3902 {
3903 MsgStrings[q].clear();
3904 }
3905 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3906 }
3907
3908 //reset the message strings
3909
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if(s_version < 7)
3910
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3911
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 init_msgstrings(0,msg_strings_size);
3912
3913 126 int32_t string_length=(s_version<2)?73:145;
3914
3915
2/2
✓ Branch 0 taken 26334 times.
✓ Branch 1 taken 126 times.
26460 for(int32_t i=0; i<temp_msg_count; i++)
3916 {
3917
1/2
✓ Branch 0 taken 26334 times.
✗ Branch 1 not taken.
26334 init_msgstr(&tempMsgString);
3918 26334 tempMsgString.listpos = i;
3919
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 26139 times.
26334 if(s_version > 8)
3920 {
3921
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_igetl(&string_length,f))
3922 {
3923 return qe_invalid;
3924 }
3925 195 }
3926
3927
2/4
✓ Branch 0 taken 26334 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26334 times.
26334 if (string_length < 0 || string_length > 8193)
3928 {
3929 return qe_invalid;
3930 }
3931
3932
1/2
✓ Branch 0 taken 26334 times.
✗ Branch 1 not taken.
26334 if (string_length > 0)
3933 {
3934
2/4
✓ Branch 0 taken 26334 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26334 times.
✗ Branch 3 not taken.
26334 if (!pfread(buf, string_length, f))
3935 {
3936 return qe_invalid;
3937 }
3938 26334 }
3939 else
3940 {
3941 buf[0] = 0;
3942 }
3943
3944
2/4
✓ Branch 0 taken 26334 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26334 times.
✗ Branch 3 not taken.
26334 if(!p_igetw(&tempMsgString.nextstring,f))
3945 {
3946 return qe_invalid;
3947 }
3948
3949
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7233 times.
26334 if(s_version<2)
3950 {
3951 19101 buf[72] = '\0';
3952
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
3953 19101 }
3954 else
3955 {
3956 // June 2008: A bug corrupted the last 4 chars of a string.
3957 // Discard these.
3958
1/2
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
7233 if(s_version<3)
3959 {
3960 for(int32_t j=140; j<144; j++)
3961 {
3962 buf[j] = '\0';
3963 }
3964 }
3965
1/2
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
7233 if(string_length > 8192) string_length = 8192;
3966 7233 buf[string_length]='\0'; //Force-terminate
3967
1/2
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
7233 tempMsgString.s = buf;
3968
3969
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 7038 times.
7233 if ( s_version >= 6 )
3970 {
3971
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_igetl(&tempMsgString.tile,f))
3972 {
3973 return qe_invalid;
3974 }
3975 195 }
3976 else
3977 {
3978
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
3979 {
3980 return qe_invalid;
3981 }
3982 }
3983
3984
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_getc(&tempMsgString.cset,f))
3985 {
3986 return qe_invalid;
3987 }
3988
3989 byte dummy_char;
3990
3991
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3992 {
3993 return qe_invalid;
3994 }
3995
3996 7233 tempMsgString.trans=dummy_char!=0;
3997
3998
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_getc(&tempMsgString.font,f))
3999 {
4000 return qe_invalid;
4001 }
4002
4003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7233 times.
7233 if(s_version < 5)
4004 {
4005 if(!p_getc(&tempMsgString.y,f))
4006 {
4007 return qe_invalid;
4008 }
4009 }
4010 else
4011 {
4012
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_igetw(&tempMsgString.x,f))
4013 {
4014 return qe_invalid;
4015 }
4016
4017
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_igetw(&tempMsgString.y,f))
4018 {
4019 return qe_invalid;
4020 }
4021
4022
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_igetw(&tempMsgString.w,f))
4023 {
4024 return qe_invalid;
4025 }
4026
4027
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_igetw(&tempMsgString.h,f))
4028 {
4029 return qe_invalid;
4030 }
4031
4032
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_getc(&tempMsgString.hspace,f))
4033 {
4034 return qe_invalid;
4035 }
4036
4037
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_getc(&tempMsgString.vspace,f))
4038 {
4039 return qe_invalid;
4040 }
4041
4042
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_getc(&tempMsgString.stringflags,f))
4043 {
4044 return qe_invalid;
4045 }
4046 }
4047
4048
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 195 times.
7233 if(s_version >= 7)
4049 {
4050
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 780 times.
975 for(int32_t q = 0; q < 4; ++q)
4051 {
4052
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempMsgString.margins[q],f))
4053 {
4054 return qe_invalid;
4055 }
4056 780 }
4057
4058
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_igetl(&tempMsgString.portrait_tile,f))
4059 {
4060 return qe_invalid;
4061 }
4062
4063
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_getc(&tempMsgString.portrait_cset,f))
4064 {
4065 return qe_invalid;
4066 }
4067
4068
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_getc(&tempMsgString.portrait_x,f))
4069 {
4070 return qe_invalid;
4071 }
4072
4073
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_getc(&tempMsgString.portrait_y,f))
4074 {
4075 return qe_invalid;
4076 }
4077
4078
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_getc(&tempMsgString.portrait_tw,f))
4079 {
4080 return qe_invalid;
4081 }
4082
4083
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_getc(&tempMsgString.portrait_th,f))
4084 {
4085 return qe_invalid;
4086 }
4087 195 }
4088
4089
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 7038 times.
7233 if(s_version >= 8)
4090 {
4091
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_getc(&tempMsgString.shadow_type,f))
4092 {
4093 return qe_invalid;
4094 }
4095
4096
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 if(!p_getc(&tempMsgString.shadow_color,f))
4097 {
4098 return qe_invalid;
4099 }
4100 195 }
4101
4102
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 7155 times.
7233 if(s_version >= 10)
4103 {
4104
2/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
78 if(!p_getc(&tempMsgString.drawlayer,f))
4105 {
4106 return qe_invalid;
4107 }
4108 78 }
4109
4110
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_getc(&tempMsgString.sfx,f))
4111 {
4112 return qe_invalid;
4113 }
4114
4115
1/2
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
7233 if(s_version>3)
4116 {
4117
2/4
✓ Branch 0 taken 7233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7233 times.
✗ Branch 3 not taken.
7233 if(!p_igetw(&tempMsgString.listpos,f))
4118 {
4119 return qe_invalid;
4120 }
4121 7233 }
4122 }
4123
4124
1/2
✓ Branch 0 taken 26334 times.
✗ Branch 1 not taken.
26334 MsgStrings[i].copyAll(tempMsgString);
4125 26334 }
4126 }
4127
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (!should_skip)
4129 130 msg_count=temp_msg_count;
4130
4131 130 return 0;
4132 130 }
4133
4134 130 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4135 {
4136
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4137
4138
2/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
130 if((Header->zelda_version < 0x192)||
4139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4140 {
4141 4 return 0;
4142 }
4143
4144 126 word temp_door_combo_set_count=0;
4145 DoorComboSet tempDoorComboSet;
4146 word dummy_word;
4147 int32_t dummy_long;
4148 byte padding;
4149 126 int32_t s_version = 0;
4150
4151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (!should_skip)
4152
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 126 times.
32382 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4153 {
4154 32256 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4155 32382 }
4156
4157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(Header->zelda_version > 0x192)
4158 {
4159 //section version info
4160
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
4161 {
4162 return qe_invalid;
4163 }
4164
4165 126 FFCore.quest_format[vDoors] = s_version;
4166
4167 //al_trace("Door combo sets version %d\n", dummy_word);
4168
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy_word,f))
4169 {
4170 return qe_invalid;
4171 }
4172
4173 //section size
4174
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy_long,f))
4175 {
4176 return qe_invalid;
4177 }
4178 126 }
4179
4180 //finally... section data
4181
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&temp_door_combo_set_count,f))
4182 {
4183 return qe_invalid;
4184 }
4185
4186
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4187 {
4188 return qe_invalid;
4189 }
4190
4191
2/2
✓ Branch 0 taken 985 times.
✓ Branch 1 taken 126 times.
1111 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4192 {
4193 985 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4194
4195 //name
4196
1/2
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
985 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4197 {
4198 return qe_invalid;
4199 }
4200
4201
1/2
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
985 if(Header->zelda_version < 0x193)
4202 {
4203 if(!p_getc(&padding,f))
4204 {
4205 return qe_invalid;
4206 }
4207 }
4208
4209 //up door
4210
2/2
✓ Branch 0 taken 8865 times.
✓ Branch 1 taken 985 times.
9850 for(int32_t j=0; j<9; j++)
4211 {
4212
2/2
✓ Branch 0 taken 35460 times.
✓ Branch 1 taken 8865 times.
44325 for(int32_t k=0; k<4; k++)
4213 {
4214
1/2
✓ Branch 0 taken 35460 times.
✗ Branch 1 not taken.
35460 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4215 {
4216 return qe_invalid;
4217 }
4218 35460 }
4219 8865 }
4220
4221
2/2
✓ Branch 0 taken 8865 times.
✓ Branch 1 taken 985 times.
9850 for(int32_t j=0; j<9; j++)
4222 {
4223
2/2
✓ Branch 0 taken 35460 times.
✓ Branch 1 taken 8865 times.
44325 for(int32_t k=0; k<4; k++)
4224 {
4225
1/2
✓ Branch 0 taken 35460 times.
✗ Branch 1 not taken.
35460 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4226 {
4227 return qe_invalid;
4228 }
4229 35460 }
4230 8865 }
4231
4232 //down door
4233
2/2
✓ Branch 0 taken 8865 times.
✓ Branch 1 taken 985 times.
9850 for(int32_t j=0; j<9; j++)
4234 {
4235
2/2
✓ Branch 0 taken 35460 times.
✓ Branch 1 taken 8865 times.
44325 for(int32_t k=0; k<4; k++)
4236 {
4237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35460 times.
35460 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4238 {
4239 return qe_invalid;
4240 }
4241 35460 }
4242 8865 }
4243
4244
2/2
✓ Branch 0 taken 8865 times.
✓ Branch 1 taken 985 times.
9850 for(int32_t j=0; j<9; j++)
4245 {
4246
2/2
✓ Branch 0 taken 35460 times.
✓ Branch 1 taken 8865 times.
44325 for(int32_t k=0; k<4; k++)
4247 {
4248
1/2
✓ Branch 0 taken 35460 times.
✗ Branch 1 not taken.
35460 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4249 {
4250 return qe_invalid;
4251 }
4252 35460 }
4253 8865 }
4254
4255 //left door
4256
2/2
✓ Branch 0 taken 8865 times.
✓ Branch 1 taken 985 times.
9850 for(int32_t j=0; j<9; j++)
4257 {
4258
2/2
✓ Branch 0 taken 53190 times.
✓ Branch 1 taken 8865 times.
62055 for(int32_t k=0; k<6; k++)
4259 {
4260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53190 times.
53190 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4261 {
4262 return qe_invalid;
4263 }
4264 53190 }
4265 8865 }
4266
4267
2/2
✓ Branch 0 taken 8865 times.
✓ Branch 1 taken 985 times.
9850 for(int32_t j=0; j<9; j++)
4268 {
4269
2/2
✓ Branch 0 taken 53190 times.
✓ Branch 1 taken 8865 times.
62055 for(int32_t k=0; k<6; k++)
4270 {
4271
1/2
✓ Branch 0 taken 53190 times.
✗ Branch 1 not taken.
53190 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4272 {
4273 return qe_invalid;
4274 }
4275 53190 }
4276 8865 }
4277
4278 //right door
4279
2/2
✓ Branch 0 taken 8865 times.
✓ Branch 1 taken 985 times.
9850 for(int32_t j=0; j<9; j++)
4280 {
4281
2/2
✓ Branch 0 taken 53190 times.
✓ Branch 1 taken 8865 times.
62055 for(int32_t k=0; k<6; k++)
4282 {
4283
1/2
✓ Branch 0 taken 53190 times.
✗ Branch 1 not taken.
53190 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4284 {
4285 return qe_invalid;
4286 }
4287 53190 }
4288 8865 }
4289
4290
2/2
✓ Branch 0 taken 8865 times.
✓ Branch 1 taken 985 times.
9850 for(int32_t j=0; j<9; j++)
4291 {
4292
2/2
✓ Branch 0 taken 53190 times.
✓ Branch 1 taken 8865 times.
62055 for(int32_t k=0; k<6; k++)
4293 {
4294
1/2
✓ Branch 0 taken 53190 times.
✗ Branch 1 not taken.
53190 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4295 {
4296 return qe_invalid;
4297 }
4298 53190 }
4299 8865 }
4300
4301 //up bomb rubble
4302
2/2
✓ Branch 0 taken 1970 times.
✓ Branch 1 taken 985 times.
2955 for(int32_t j=0; j<2; j++)
4303 {
4304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970 times.
1970 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4305 {
4306 return qe_invalid;
4307 }
4308 1970 }
4309
4310
2/2
✓ Branch 0 taken 1970 times.
✓ Branch 1 taken 985 times.
2955 for(int32_t j=0; j<2; j++)
4311 {
4312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970 times.
1970 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4313 {
4314 return qe_invalid;
4315 }
4316 1970 }
4317
4318 //down bomb rubble
4319
2/2
✓ Branch 0 taken 1970 times.
✓ Branch 1 taken 985 times.
2955 for(int32_t j=0; j<2; j++)
4320 {
4321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970 times.
1970 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4322 {
4323 return qe_invalid;
4324 }
4325 1970 }
4326
4327
2/2
✓ Branch 0 taken 1970 times.
✓ Branch 1 taken 985 times.
2955 for(int32_t j=0; j<2; j++)
4328 {
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970 times.
1970 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4330 {
4331 return qe_invalid;
4332 }
4333 1970 }
4334
4335 //left bomb rubble
4336
2/2
✓ Branch 0 taken 2955 times.
✓ Branch 1 taken 985 times.
3940 for(int32_t j=0; j<3; j++)
4337 {
4338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2955 times.
2955 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4339 {
4340 return qe_invalid;
4341 }
4342 2955 }
4343
4344
2/2
✓ Branch 0 taken 2955 times.
✓ Branch 1 taken 985 times.
3940 for(int32_t j=0; j<3; j++)
4345 {
4346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2955 times.
2955 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4347 {
4348 return qe_invalid;
4349 }
4350 2955 }
4351
4352
1/2
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
985 if(Header->zelda_version < 0x193)
4353 {
4354 if(!p_getc(&padding,f))
4355 {
4356 return qe_invalid;
4357 }
4358
4359 }
4360
4361 //right bomb rubble
4362
2/2
✓ Branch 0 taken 2955 times.
✓ Branch 1 taken 985 times.
3940 for(int32_t j=0; j<3; j++)
4363 {
4364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2955 times.
2955 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4365 {
4366 return qe_invalid;
4367 }
4368 2955 }
4369
4370
2/2
✓ Branch 0 taken 2955 times.
✓ Branch 1 taken 985 times.
3940 for(int32_t j=0; j<3; j++)
4371 {
4372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2955 times.
2955 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4373 {
4374 return qe_invalid;
4375 }
4376 2955 }
4377
4378
1/2
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
985 if(Header->zelda_version < 0x193)
4379 {
4380 if(!p_getc(&padding,f))
4381 {
4382 return qe_invalid;
4383 }
4384 }
4385
4386 //walkthrough stuff
4387
2/2
✓ Branch 0 taken 3940 times.
✓ Branch 1 taken 985 times.
4925 for(int32_t j=0; j<4; j++)
4388 {
4389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3940 times.
3940 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4390 {
4391 return qe_invalid;
4392 }
4393 3940 }
4394
4395
2/2
✓ Branch 0 taken 3940 times.
✓ Branch 1 taken 985 times.
4925 for(int32_t j=0; j<4; j++)
4396 {
4397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3940 times.
3940 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4398 {
4399 return qe_invalid;
4400 }
4401 3940 }
4402
4403 //flags
4404
2/2
✓ Branch 0 taken 1970 times.
✓ Branch 1 taken 985 times.
2955 for(int32_t j=0; j<2; j++)
4405 {
4406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970 times.
1970 if(!p_getc(&tempDoorComboSet.flags[j],f))
4407 {
4408 return qe_invalid;
4409 }
4410 1970 }
4411
4412
1/2
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
985 if(Header->zelda_version < 0x193)
4413 {
4414 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4415 {
4416 return qe_invalid;
4417 }
4418 }
4419
4420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985 times.
985 if (!should_skip)
4421 985 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4422 985 }
4423
4424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (!should_skip)
4425 126 door_combo_set_count=temp_door_combo_set_count;
4426
4427 126 return 0;
4428 130 }
4429
4430 int32_t count_dmaps()
4431 {
4432 int32_t i=MAXDMAPS-1;
4433 bool found=false;
4434
4435 while(i>=0 && !found)
4436 {
4437 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4438 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4439 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4440 found=true;
4441
4442 for(int32_t j=0; j<8; j++)
4443 {
4444 if(DMaps[i].grid[j]!=0)
4445
4446 found=true;
4447 }
4448
4449 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4450 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4451 found=true;
4452
4453 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4454 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4455 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4456 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4457 found=true;
4458
4459 if(!found)
4460 {
4461 i--;
4462 }
4463 }
4464
4465 return i+1;
4466 }
4467
4468
4469 int32_t count_shops(miscQdata *Misc)
4470 {
4471 int32_t i=NUM_SHOPS-1,j;
4472 bool found=false;
4473
4474 while(i>=0 && !found)
4475 {
4476 j=2;
4477
4478 while(j>=0 && !found)
4479 {
4480 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4481 {
4482 found=true;
4483 }
4484 else
4485 {
4486 j--;
4487 }
4488 }
4489
4490 if(Misc->shop[i].name[0]!=0)
4491 {
4492 found=true;
4493 }
4494
4495 if(!found)
4496 {
4497 i--;
4498 }
4499 }
4500
4501 return i+1;
4502 }
4503
4504 int32_t count_infos(miscQdata *Misc)
4505 {
4506 int32_t i=255,j;
4507 bool found=false;
4508
4509 while(i>=0 && !found)
4510 {
4511 j=2;
4512
4513 while(j>=0 && !found)
4514 {
4515 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4516 {
4517 found=true;
4518 }
4519 else
4520 {
4521 j--;
4522 }
4523 }
4524
4525 if(Misc->info[i].name[0]!=0)
4526 {
4527 found=true;
4528 }
4529
4530 if(!found)
4531 {
4532 i--;
4533 }
4534 }
4535
4536 return i+1;
4537 }
4538
4539 int32_t count_warprings(miscQdata *Misc)
4540 {
4541 int32_t i=15,j;
4542 bool found=false;
4543
4544 while(i>=0 && !found)
4545 {
4546 j=7;
4547
4548 while(j>=0 && !found)
4549 {
4550 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4551 {
4552 found=true;
4553 }
4554 else
4555 {
4556 j--;
4557 }
4558 }
4559
4560 if(!found)
4561 {
4562 i--;
4563 }
4564 }
4565
4566 return i+1;
4567 }
4568
4569 int32_t count_palcycles(miscQdata *Misc)
4570 {
4571 int32_t i=255,j;
4572 bool found=false;
4573
4574 while(i>=0 && !found)
4575 {
4576 j=2;
4577
4578 while(j>=0 && !found)
4579 {
4580 if(Misc->cycles[i][j].count!=0)
4581 {
4582 found=true;
4583 }
4584 else
4585 {
4586 j--;
4587 }
4588 }
4589
4590 if(!found)
4591 {
4592 i--;
4593 }
4594 }
4595
4596 return i+1;
4597 }
4598
4599 258458 void clear_screen(mapscr *temp_scr)
4600 {
4601 258458 temp_scr->zero_memory();
4602 258458 }
4603
4604 130 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4605 {
4606
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4607
4608 130 word dmapstoread=0;
4609 130 dmap tempDMap;
4610
4611 int32_t dummy;
4612 130 word s_version=0, s_cversion=0;
4613 byte padding;
4614
4615 char legacy_title[22];
4616
4617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (!should_skip)
4618
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<max_dmaps; i++)
4619 {
4620
1/2
✓ Branch 0 taken 66560 times.
✗ Branch 1 not taken.
66560 DMaps[start_dmap + i].clear();
4621 66560 sprintf(legacy_title," ");
4622 66560 sprintf(DMaps[start_dmap+i].intro," ");
4623 66560 DMaps[start_dmap+i].type |= dmCAVE;
4624 66690 }
4625
4626
3/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 4 times.
130 if(!Header || Header->zelda_version > 0x192)
4627 {
4628 //section version info
4629
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_version,f))
4630 {
4631 return qe_invalid;
4632 }
4633
4634 126 FFCore.quest_format[vDMaps] = s_version;
4635
4636 //al_trace("DMaps version %d\n", s_version);
4637
4638
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_cversion,f))
4639 {
4640 return qe_invalid;
4641 }
4642
4643 //section size
4644
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetl(&dummy,f))
4645 {
4646 return qe_invalid;
4647 }
4648
4649 //finally... section data
4650
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&dmapstoread,f))
4651 {
4652 return qe_invalid;
4653 }
4654 126 }
4655 else
4656 {
4657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4658 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4659 {
4660 4 dmapstoread=32;
4661 4 }
4662 else if(s_version <= 4)
4663 {
4664 dmapstoread=OLDMAXDMAPS;
4665 }
4666 else
4667 {
4668 dmapstoread=MAXDMAPS;
4669 }
4670 }
4671
4672
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 dmapstoread=zc_min(dmapstoread, max_dmaps);
4673
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4674
4675
2/2
✓ Branch 0 taken 61568 times.
✓ Branch 1 taken 130 times.
61698 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4676 {
4677
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 tempDMap.clear();
4678 61568 sprintf(legacy_title," ");
4679 61568 sprintf(tempDMap.intro," ");
4680
4681
2/4
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61568 times.
✗ Branch 3 not taken.
61568 if(!p_getc(&tempDMap.map,f))
4682 {
4683 return qe_invalid;
4684 }
4685
4686
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 58368 times.
61568 if(s_version <= 4)
4687 {
4688 byte tempbyte;
4689
4690
2/4
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3200 times.
✗ Branch 3 not taken.
3200 if(!p_getc(&tempbyte,f))
4691 {
4692 return qe_invalid;
4693 }
4694
4695 3200 tempDMap.level=(word)tempbyte;
4696 3200 }
4697 else
4698 {
4699
2/4
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58368 times.
✗ Branch 3 not taken.
58368 if(!p_igetw(&tempDMap.level,f))
4700 {
4701 return qe_invalid;
4702 }
4703 }
4704
4705
2/4
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61568 times.
✗ Branch 3 not taken.
61568 if(!p_getc(&tempDMap.xoff,f))
4706 {
4707 return qe_invalid;
4708 }
4709
4710
2/4
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61568 times.
✗ Branch 3 not taken.
61568 if(!p_getc(&tempDMap.compass,f))
4711 {
4712 return qe_invalid;
4713 }
4714
4715
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version > 8) // February 2009
4716 {
4717
2/4
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58368 times.
✗ Branch 3 not taken.
58368 if(!p_igetw(&tempDMap.color,f))
4718 {
4719 return qe_invalid;
4720 }
4721 58368 }
4722 else
4723 {
4724 byte tempbyte;
4725
4726
2/4
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3200 times.
✗ Branch 3 not taken.
3200 if(!p_getc(&tempbyte,f))
4727 {
4728 return qe_invalid;
4729 }
4730
4731 3200 tempDMap.color = (word)tempbyte;
4732 }
4733
4734
2/4
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61568 times.
✗ Branch 3 not taken.
61568 if(!p_getc(&tempDMap.midi,f))
4735 {
4736 return qe_invalid;
4737 }
4738
4739
2/4
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61568 times.
✗ Branch 3 not taken.
61568 if(!p_getc(&tempDMap.cont,f))
4740 {
4741 return qe_invalid;
4742 }
4743
4744
2/4
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61568 times.
✗ Branch 3 not taken.
61568 if(!p_getc(&tempDMap.type,f))
4745 {
4746 return qe_invalid;
4747 }
4748
4749
4/4
✓ Branch 0 taken 818 times.
✓ Branch 1 taken 60750 times.
✓ Branch 2 taken 806 times.
✓ Branch 3 taken 12 times.
62386 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4750
1/2
✓ Branch 0 taken 818 times.
✗ Branch 1 not taken.
818 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4751 806 tempDMap.xoff = 0;
4752
4753
2/2
✓ Branch 0 taken 61568 times.
✓ Branch 1 taken 492544 times.
554112 for(int32_t j=0; j<8; j++)
4754 {
4755
2/4
✓ Branch 0 taken 492544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 492544 times.
✗ Branch 3 not taken.
492544 if(!p_getc(&tempDMap.grid[j],f))
4756 {
4757 return qe_invalid;
4758 }
4759 492544 }
4760
4761
4/6
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61440 times.
61568 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4762 {
4763
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4764 {
4765 38 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4766 38 }
4767
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 tempDMap.title.assign(legacy_title);
4768
4769
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4770 {
4771 4 tempDMap.cont-=tempDMap.xoff;
4772 4 tempDMap.compass-=tempDMap.xoff;
4773 4 }
4774
4775 //forgotten -DD
4776
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4777 {
4778 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4779 90 }
4780 128 }
4781 else
4782 {
4783
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4784 {
4785 return qe_invalid;
4786 }
4787
4788
2/2
✓ Branch 0 taken 46592 times.
✓ Branch 1 taken 14848 times.
61440 if(s_version<20)
4789 {
4790
2/4
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46592 times.
✗ Branch 3 not taken.
46592 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4791 {
4792 return qe_invalid;
4793 }
4794
1/2
✓ Branch 0 taken 46592 times.
✗ Branch 1 not taken.
46592 tempDMap.title.assign(legacy_title);
4795 46592 }
4796 else
4797 {
4798 14848 std::string tmptitle;
4799
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_getwstr(&tmptitle, f))
4800 {
4801 return qe_invalid;
4802 }
4803
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 tempDMap.title.reserve(tmptitle.size());
4804
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 tempDMap.title = tmptitle;
4805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 }
4806
4807
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4808 {
4809 return qe_invalid;
4810 }
4811
4812
3/8
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 61440 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61440 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4813 {
4814 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4815 DMaps[i] = tempDMap;
4816
4817 continue;
4818 }
4819
4820
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61440 times.
61440 if(Header && (Header->zelda_version < 0x193))
4821 {
4822 if(!p_getc(&padding,f))
4823 {
4824 return qe_invalid;
4825 }
4826 }
4827
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42496 times.
61440 if ( s_version >= 11 )
4828 {
4829
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
18944 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4830 {
4831 return qe_invalid;
4832 }
4833 18944 }
4834 else
4835 {
4836
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4837 {
4838 return qe_invalid;
4839 }
4840 }
4841
4842
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(!p_getc(&tempDMap.minimap_1_cset,f))
4843 {
4844 return qe_invalid;
4845 }
4846
4847
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61440 times.
61440 if(Header && (Header->zelda_version < 0x193))
4848 {
4849 if(!p_getc(&padding,f))
4850 {
4851 return qe_invalid;
4852 }
4853 }
4854
4855
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42496 times.
61440 if ( s_version >= 11 )
4856 {
4857
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
18944 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4858 {
4859 return qe_invalid;
4860 }
4861 18944 }
4862 else
4863 {
4864
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4865 {
4866 return qe_invalid;
4867 }
4868 }
4869
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(!p_getc(&tempDMap.minimap_2_cset,f))
4870 {
4871 return qe_invalid;
4872 }
4873
4874
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61440 times.
61440 if(Header && (Header->zelda_version < 0x193))
4875 {
4876 if(!p_getc(&padding,f))
4877 {
4878 return qe_invalid;
4879 }
4880 }
4881
4882
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42496 times.
61440 if ( s_version >= 11 )
4883 {
4884
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18944 times.
18944 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4885 {
4886 return qe_invalid;
4887 }
4888 18944 }
4889 else
4890 {
4891
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42496 times.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4892 {
4893 return qe_invalid;
4894 }
4895 }
4896
4897
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(!p_getc(&tempDMap.largemap_1_cset,f))
4898 {
4899 return qe_invalid;
4900 }
4901
4902
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61440 times.
61440 if(Header && (Header->zelda_version < 0x193))
4903 {
4904
4905 if(!p_getc(&padding,f))
4906 {
4907 return qe_invalid;
4908 }
4909 }
4910
4911
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42496 times.
61440 if ( s_version >= 11 )
4912 {
4913
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
18944 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4914 {
4915 return qe_invalid;
4916 }
4917 18944 }
4918 else
4919 {
4920
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4921 {
4922 return qe_invalid;
4923 }
4924 }
4925
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(!p_getc(&tempDMap.largemap_2_cset,f))
4926 {
4927 return qe_invalid;
4928 }
4929
4930
2/4
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61440 times.
✗ Branch 3 not taken.
61440 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4931 {
4932 return qe_invalid;
4933 }
4934 }
4935
4936
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version>1)
4937 {
4938
2/4
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58368 times.
✗ Branch 3 not taken.
58368 if(!p_getc(&tempDMap.tmusictrack,f))
4939 {
4940 return qe_invalid;
4941 }
4942
4943
2/4
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58368 times.
✗ Branch 3 not taken.
58368 if(!p_getc(&tempDMap.active_subscreen,f))
4944 {
4945 return qe_invalid;
4946 }
4947
4948
2/4
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58368 times.
✗ Branch 3 not taken.
58368 if(!p_getc(&tempDMap.passive_subscreen,f))
4949 {
4950 return qe_invalid;
4951 }
4952 58368 }
4953
4954
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version>2)
4955 {
4956 byte di[32];
4957
4958
2/4
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58368 times.
✗ Branch 3 not taken.
58368 if(!pfread(&di, 32, f)) return qe_invalid;
4959
4960
2/2
✓ Branch 0 taken 14942208 times.
✓ Branch 1 taken 58368 times.
15000576 for(int32_t j=0; j<MAXITEMS; j++)
4961 {
4962
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14942201 times.
14942208 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4963 14942201 else tempDMap.disableditems[j]=0;
4964 14942208 }
4965 58368 }
4966
4967
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version >= 6)
4968 {
4969
2/4
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58368 times.
✗ Branch 3 not taken.
58368 if(!p_igetl(&tempDMap.flags,f))
4970 {
4971 return qe_invalid;
4972 }
4973 58368 }
4974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
4975 {
4976 char temp;
4977
4978 if(!p_getc(&temp,f))
4979 {
4980 return qe_invalid;
4981 }
4982
4983 tempDMap.flags = temp;
4984 }
4985
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4986 {
4987 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4988 816 }
4989 else
4990 2384 tempDMap.flags=0;
4991
4992
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version<7)
4993 {
4994
4/6
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 816 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 816 times.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4995 816 tempDMap.flags|= dmfVIEWMAP;
4996 3200 }
4997
4998
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 3200 times.
61568 if(s_version<8)
4999 {
5000
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5001 {
5002 609 tempDMap.type &= ~dmDNGN;
5003 609 tempDMap.type |= dmCAVE;
5004 609 }
5005
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5006 {
5007 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5008 1736 }
5009 3200 }
5010
5011
5/8
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 61440 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 61440 times.
61568 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5012 61440 && (Header->zelda_version < 0x193))
5013 {
5014 if(!p_getc(&padding,f))
5015 {
5016 return qe_invalid;
5017 }
5018 }
5019
5020
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18944 times.
61568 if(s_version >= 10)
5021 {
5022
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
18944 if(!p_getc(&tempDMap.sideview,f))
5023 {
5024 return qe_invalid;
5025 }
5026 18944 }
5027
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if(s_version < 10) tempDMap.sideview = 0;
5028
5029 //Dmap Scripts
5030
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if(s_version >= 12)
5031 {
5032
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
18944 if(!p_igetw(&tempDMap.script,f))
5033 {
5034 return qe_invalid;
5035 }
5036
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
5037 {
5038
2/4
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151552 times.
✗ Branch 3 not taken.
151552 if(!p_igetl(&tempDMap.initD[q],f))
5039 {
5040 return qe_invalid;
5041 }
5042 151552 }
5043 18944 }
5044
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if ( s_version < 12 )
5045 {
5046 42624 tempDMap.script = 0;
5047
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5048 {
5049 340992 tempDMap.initD[q] = 0;
5050 340992 }
5051 42624 }
5052
5053
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18944 times.
61568 if(s_version >= 13)
5054 {
5055
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
5056 {
5057
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; w++ )
5058 {
5059
2/4
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9850880 times.
✗ Branch 3 not taken.
9850880 if(!p_getc(&tempDMap.initD_label[q][w],f))
5060 {
5061 return qe_invalid;
5062 }
5063 9850880 }
5064 151552 }
5065 18944 }
5066
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if ( s_version < 13 )
5067 {
5068 42624 tempDMap.script = 0;
5069
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5070 {
5071
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5072 22164480 tempDMap.initD_label[q][w] = 0;
5073 340992 }
5074 42624 }
5075
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if(s_version >= 14)
5076 {
5077
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
18944 if(!p_igetw(&tempDMap.active_sub_script,f))
5078 {
5079 return qe_invalid;
5080 }
5081
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
18944 if(!p_igetw(&tempDMap.passive_sub_script,f))
5082 {
5083 return qe_invalid;
5084 }
5085
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; ++q )
5086 {
5087
2/4
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151552 times.
✗ Branch 3 not taken.
151552 if(!p_igetl(&tempDMap.sub_initD[q],f))
5088 {
5089 return qe_invalid;
5090 }
5091 151552 }
5092
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for(int32_t q = 0; q < 8; ++q)
5093 {
5094
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; ++w )
5095 {
5096
2/4
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9850880 times.
✗ Branch 3 not taken.
9850880 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5097 {
5098 return qe_invalid;
5099 }
5100 9850880 }
5101 151552 }
5102 18944 }
5103 else
5104 {
5105 42624 tempDMap.active_sub_script = 0;
5106 42624 tempDMap.passive_sub_script = 0;
5107
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5108 {
5109 340992 tempDMap.sub_initD[q] = 0;
5110
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5111 22164480 tempDMap.sub_initD_label[q][w] = 0;
5112 340992 }
5113 }
5114
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if(s_version >= 15)
5115 {
5116
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
18944 if(!p_igetw(&tempDMap.onmap_script,f))
5117 {
5118 return qe_invalid;
5119 }
5120
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; ++q )
5121 {
5122
2/4
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151552 times.
✗ Branch 3 not taken.
151552 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5123 {
5124 return qe_invalid;
5125 }
5126 151552 }
5127
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for(int32_t q = 0; q < 8; ++q)
5128 {
5129
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; ++w )
5130 {
5131
2/4
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9850880 times.
✗ Branch 3 not taken.
9850880 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5132 {
5133 return qe_invalid;
5134 }
5135 9850880 }
5136 151552 }
5137 18944 }
5138 else
5139 {
5140 42624 tempDMap.onmap_script = 0;
5141
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5142 {
5143 340992 tempDMap.onmap_initD[q] = 0;
5144
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5145 {
5146 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5147 22164480 }
5148 340992 }
5149 }
5150
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 42624 times.
61568 if(s_version >= 16)
5151 {
5152
2/4
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
18944 if(!p_igetw(&tempDMap.mirrorDMap,f))
5153 {
5154 return qe_invalid;
5155 }
5156 18944 }
5157 else
5158 {
5159 42624 tempDMap.mirrorDMap = -1;
5160 }
5161
5162
2/2
✓ Branch 0 taken 46720 times.
✓ Branch 1 taken 14848 times.
61568 if (s_version >= 17)
5163 {
5164 // Reserved for z3.
5165 14848 }
5166
5167 // Enhanced music loop points
5168
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 46720 times.
61568 if (s_version >= 18)
5169 {
5170
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5171 {
5172 return qe_invalid;
5173 }
5174
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5175 {
5176 return qe_invalid;
5177 }
5178
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5179 {
5180 return qe_invalid;
5181 }
5182
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5183 {
5184 return qe_invalid;
5185 }
5186 14848 }
5187 else
5188 {
5189 46720 tempDMap.tmusic_loop_start = 0;
5190 46720 tempDMap.tmusic_loop_end = 0;
5191 46720 tempDMap.tmusic_xfade_in = 0;
5192 46720 tempDMap.tmusic_xfade_out = 0;
5193 }
5194
5195
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 46720 times.
61568 if(s_version >= 19)
5196
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if(!p_getc(&tempDMap.overlay_subscreen, f))
5197 return qe_invalid;
5198
5199
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 46720 times.
61568 if (s_version >= 20)
5200 {
5201
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.intro_string_id, f))
5202 return qe_invalid;
5203 14848 }
5204 else
5205 46720 tempDMap.intro_string_id = 0;
5206
5207 // Reserved for z3.
5208
2/2
✓ Branch 0 taken 46720 times.
✓ Branch 1 taken 14848 times.
61568 if(s_version >= 21)
5209 {
5210
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for(int32_t j=0; j<8; j++)
5211 {
5212
2/2
✓ Branch 0 taken 950272 times.
✓ Branch 1 taken 118784 times.
1069056 for(int32_t k=0; k<8; k++)
5213 {
5214 char c;
5215
2/4
✓ Branch 0 taken 950272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 950272 times.
✗ Branch 3 not taken.
950272 if(!p_getc(&c,f))
5216 {
5217 return qe_invalid;
5218 }
5219 950272 }
5220 118784 }
5221 14848 }
5222
5223
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 if (!should_skip)
5224 {
5225
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 if(loading_tileset_flags & TILESET_CLEARMAPS)
5226 tempDMap.map = 0;
5227
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5228 {
5229 tempDMap.script = 0;
5230 for(int q = 0; q < 8; ++q)
5231 tempDMap.initD[q] = 0;
5232 }
5233
1/2
✓ Branch 0 taken 61568 times.
✗ Branch 1 not taken.
61568 DMaps[i] = tempDMap;
5234 61568 }
5235 61568 }
5236
5237 130 return 0;
5238 130 }
5239
5240 114 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5241 {
5242 //these are here to bypass compiler warnings about unused arguments
5243 114 Header=Header;
5244
5245 miscQdata temp_misc;
5246 114 word s_version=0, s_cversion=0;
5247 114 int32_t tempsize=0;
5248 word dummyw;
5249
5250 114 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5251
5252 //section version info
5253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
5254 {
5255 return qe_invalid;
5256 }
5257
5258 114 FFCore.quest_format[vColours] = s_version;
5259
5260 114 al_trace("Misc Colours section version: %d\n", s_version);
5261
5262 //al_trace("Misc. colors version %d\n", s_version);
5263
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
5264 {
5265 return qe_invalid;
5266 }
5267
5268
5269 //section size
5270
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&tempsize,f))
5271 {
5272 return qe_invalid;
5273 }
5274
5275 //finally... section data
5276 114 readsize=0;
5277
5278
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.text,f))
5279 {
5280 return qe_invalid;
5281 }
5282
5283
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.caption,f))
5284 {
5285 return qe_invalid;
5286 }
5287
5288
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.overw_bg,f))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5294 {
5295 return qe_invalid;
5296 }
5297
5298
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5299 {
5300 return qe_invalid;
5301 }
5302
5303
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.cave_fg,f))
5304 {
5305 return qe_invalid;
5306 }
5307
5308
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.bs_dk,f))
5309 {
5310 return qe_invalid;
5311 }
5312
5313
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.bs_goal,f))
5314 {
5315 return qe_invalid;
5316 }
5317
5318
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.compass_lt,f))
5319 {
5320 return qe_invalid;
5321 }
5322
5323
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.compass_dk,f))
5324 {
5325 return qe_invalid;
5326 }
5327
5328
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5329 {
5330 return qe_invalid;
5331 }
5332
5333
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.triframe_color,f))
5334 {
5335 return qe_invalid;
5336 }
5337
5338
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.hero_dot,f))
5339 {
5340 return qe_invalid;
5341 }
5342
5343
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5344 {
5345 return qe_invalid;
5346 }
5347
5348
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5349 {
5350 return qe_invalid;
5351 }
5352
5353
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5354 {
5355 return qe_invalid;
5356 }
5357
5358
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5359 {
5360 return qe_invalid;
5361 }
5362
5363
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5364 {
5365 return qe_invalid;
5366 }
5367
5368
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5369 {
5370 return qe_invalid;
5371 }
5372
5373
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5374 {
5375 return qe_invalid;
5376 }
5377
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(s_version < 4)
5378 {
5379
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5380 return qe_invalid;
5381 77 temp_misc.colors.triforce_tile = dummyw;
5382
5383
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5384 return qe_invalid;
5385 77 temp_misc.colors.triframe_tile = dummyw;
5386
5387
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5388 return qe_invalid;
5389 77 temp_misc.colors.overworld_map_tile = dummyw;
5390
5391
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5392 return qe_invalid;
5393 77 temp_misc.colors.dungeon_map_tile = dummyw;
5394
5395
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5396 return qe_invalid;
5397 77 temp_misc.colors.blueframe_tile = dummyw;
5398
5399
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5400 return qe_invalid;
5401 77 temp_misc.colors.HCpieces_tile = dummyw;
5402 77 }
5403
5404
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5405 {
5406 return qe_invalid;
5407 }
5408
5409
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5410 {
5411 return qe_invalid;
5412 }
5413
5414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version < 2)
5415 {
5416 temp_misc.colors.msgtext = 0x01;
5417 }
5418 else
5419 {
5420
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&temp_misc.colors.msgtext, f))
5421 {
5422 return qe_invalid;
5423 }
5424 }
5425
5426
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if ( s_version >= 3 ) //expanded tile pages to 825
5427 {
5428
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5429 {
5430 return qe_invalid;
5431 }
5432
5433
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5434 {
5435 return qe_invalid;
5436 }
5437
5438
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5439 {
5440 return qe_invalid;
5441 }
5442
5443
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5444 {
5445 return qe_invalid;
5446 }
5447
5448
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5449 {
5450 return qe_invalid;
5451 }
5452
5453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5454 {
5455 return qe_invalid;
5456 }
5457 37 }
5458
5459 114 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5460
5461 114 return 0;
5462 114 }
5463
5464 114 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5465 {
5466 miscQdata temp_misc;
5467 114 word s_version=0, s_cversion=0;
5468 byte icons;
5469 114 int32_t tempsize=0;
5470
5471 114 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5472
5473 //section version info
5474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
5475 {
5476 return qe_invalid;
5477 }
5478
5479 114 FFCore.quest_format[vIcons] = s_version;
5480
5481 //al_trace("Game icons version %d\n", s_version);
5482
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
5483 {
5484 return qe_invalid;
5485 }
5486
5487
5488 //section size
5489
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&tempsize,f))
5490 {
5491 return qe_invalid;
5492 }
5493
5494 //finally... section data
5495 114 readsize=0;
5496
5497 114 icons=4;
5498
5499
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if ( s_version >= 10 )
5500 {
5501
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<icons; i++)
5502 {
5503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&temp_misc.icons[i],f))
5504 {
5505 return qe_invalid;
5506 }
5507 148 }
5508 37 }
5509 else
5510 {
5511
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5512 {
5513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5514 {
5515 return qe_invalid;
5516 }
5517 308 }
5518 }
5519
5520 114 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5521
5522 114 return 0;
5523 114 }
5524
5525 130 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5526 {
5527
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5528
5529 130 word maxinfos=256;
5530 130 word maxshops=256;
5531 130 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5532 130 word ponds=16, pondsize=72, expansionsize=98*2;
5533 byte tempbyte, padding;
5534 miscQdata temp_misc;
5535 130 word s_version=0, s_cversion=0;
5536 word swaptmp;
5537 130 int32_t tempsize=0;
5538
5539 130 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5540
5541
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<maxshops; ++i)
5542 {
5543 33280 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5544 33280 }
5545
5546
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<maxinfos; ++i)
5547 {
5548 33280 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5549 33280 }
5550
5551
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
5552 {
5553 //section version info
5554
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
5555 {
5556 return qe_invalid;
5557 }
5558
5559 126 FFCore.quest_format[vMisc] = s_version;
5560
5561 //al_trace("Misc. data version %d\n", s_version);
5562
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_cversion,f))
5563 {
5564 return qe_invalid;
5565 }
5566
5567
5568 //section size
5569
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&tempsize,f))
5570 {
5571 return qe_invalid;
5572 }
5573 126 }
5574
5575 //finally... section data
5576 130 readsize=0;
5577
5578 //shops
5579
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
5580 {
5581
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&shops,f))
5582 {
5583 return qe_invalid;
5584 }
5585 126 }
5586
5587
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
130 if (!(shops >= 0 && shops <= NUM_SHOPS))
5588 {
5589 return qe_invalid;
5590 }
5591
5592
2/2
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 130 times.
1618 for(int32_t i=0; i<shops; i++)
5593 {
5594
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1265 times.
1488 if(s_version > 6)
5595 {
5596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1265 times.
1265 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5597 {
5598 return qe_invalid;
5599 }
5600 1265 }
5601
5602
2/2
✓ Branch 0 taken 4464 times.
✓ Branch 1 taken 1488 times.
5952 for(int32_t j=0; j<3; j++)
5603 {
5604
1/2
✓ Branch 0 taken 4464 times.
✗ Branch 1 not taken.
4464 if(!p_getc(&temp_misc.shop[i].item[j],f))
5605 {
5606 return qe_invalid;
5607 }
5608
5609
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 669 times.
4464 if(s_version < 4)
5610 {
5611 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5612 669 }
5613 4464 }
5614
5615
2/2
✓ Branch 0 taken 1424 times.
✓ Branch 1 taken 64 times.
1488 if(Header->zelda_version < 0x193)
5616 {
5617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5618 {
5619 return qe_invalid;
5620 }
5621 64 }
5622
5623
2/2
✓ Branch 0 taken 4464 times.
✓ Branch 1 taken 1488 times.
5952 for(int32_t j=0; j<3; j++)
5624 {
5625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4464 times.
4464 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5626 {
5627 return qe_invalid;
5628 }
5629 4464 }
5630
5631
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1265 times.
1488 if(s_version > 3)
5632 {
5633
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 1265 times.
5060 for(int32_t j=0; j<3; j++)
5634 {
5635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3795 times.
3795 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5636 return qe_invalid;
5637 3795 }
5638 1265 }
5639
5640 /*
5641 if(s_version < 8)
5642 {
5643 for(int32_t j=0; j<3; j++)
5644 {
5645 (&temp_misc.shop[i].str[j])=0; //initialise.
5646 }
5647 }
5648 */
5649 1488 }
5650
5651 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5652
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<maxshops; ++i)
5653 {
5654
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 33280 times.
99840 for(int32_t j=0; j<3-1; j++)
5655 {
5656
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 96813 times.
163373 for(int32_t k=0; k<2-j; k++)
5657 {
5658 96813 if(temp_misc.shop[i].hasitem[k]==0)
5659 {
5660 96813 swaptmp = temp_misc.shop[i].item[k];
5661 96813 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5662 96813 temp_misc.shop[i].item[k+1] = swaptmp;
5663 96813 swaptmp = temp_misc.shop[i].price[k];
5664 96813 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5665 96813 temp_misc.shop[i].price[k+1] = swaptmp;
5666 96813 swaptmp = temp_misc.shop[i].hasitem[k];
5667 96813 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5668 96813 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5669 96813 }
5670 96813 }
5671 66560 }
5672 33280 }
5673
5674 //infos
5675
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
5676 {
5677
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&infos,f))
5678 {
5679 return qe_invalid;
5680 }
5681 126 }
5682
5683
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
130 if (!(infos >= 0 && infos <= NUM_INFOS))
5684 {
5685 return qe_invalid;
5686 }
5687
5688
5689
2/2
✓ Branch 0 taken 1799 times.
✓ Branch 1 taken 130 times.
1929 for(int32_t i=0; i<infos; i++)
5690 {
5691
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1699 times.
1799 if(s_version > 6)
5692 {
5693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1699 times.
1699 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5694 {
5695 return qe_invalid;
5696 }
5697 1699 }
5698
5699
2/2
✓ Branch 0 taken 5397 times.
✓ Branch 1 taken 1799 times.
7196 for(int32_t j=0; j<3; j++)
5700 {
5701
2/4
✓ Branch 0 taken 5205 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5397 if((Header->zelda_version < 0x192)||
5702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5205 times.
5205 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5703 {
5704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5705 {
5706 return qe_invalid;
5707 }
5708
5709 192 temp_misc.info[i].str[j]=tempbyte;
5710 192 }
5711 else
5712 {
5713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5205 times.
5205 if(!p_igetw(&temp_misc.info[i].str[j],f))
5714 {
5715 return qe_invalid;
5716 }
5717 }
5718 5397 }
5719
5720
2/2
✓ Branch 0 taken 1735 times.
✓ Branch 1 taken 64 times.
1799 if(Header->zelda_version < 0x193)
5721 {
5722
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5723 {
5724 return qe_invalid;
5725 }
5726 64 }
5727
5728
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1799 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1799 if((Header->zelda_version == 0x192)&&(Header->build>145))
5729 {
5730 if(!p_getc(&padding,f))
5731 {
5732 return qe_invalid;
5733 }
5734 }
5735
5736
2/2
✓ Branch 0 taken 5397 times.
✓ Branch 1 taken 1799 times.
7196 for(int32_t j=0; j<3; j++)
5737 {
5738
1/2
✓ Branch 0 taken 5397 times.
✗ Branch 1 not taken.
5397 if(!p_igetw(&temp_misc.info[i].price[j],f))
5739 {
5740 return qe_invalid;
5741 }
5742 5397 }
5743 1799 }
5744
5745 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5746
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<maxinfos; ++i)
5747 {
5748
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 33280 times.
99840 for(int32_t j=0; j<3-1; j++)
5749 {
5750
2/2
✓ Branch 0 taken 99840 times.
✓ Branch 1 taken 66560 times.
166400 for(int32_t k=0; k<2-j; k++)
5751 {
5752
2/2
✓ Branch 0 taken 2130 times.
✓ Branch 1 taken 97710 times.
99840 if(temp_misc.info[i].str[k]==0)
5753 {
5754 97710 swaptmp = temp_misc.info[i].str[k];
5755 97710 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5756 97710 temp_misc.info[i].str[k+1] = swaptmp;
5757 97710 swaptmp = temp_misc.info[i].price[k];
5758 97710 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5759 97710 temp_misc.info[i].price[k+1] = swaptmp;
5760 97710 }
5761 99840 }
5762 66560 }
5763 33280 }
5764
5765
5766 //warp rings
5767
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 if(s_version > 5)
5768 114 warprings++;
5769
5770
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
5771 {
5772
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&warprings,f))
5773 {
5774 return qe_invalid;
5775 }
5776
5777
3/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 38 times.
126 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5778 {
5779 // return qe_invalid;
5780 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5781 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5782 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5783 38 }
5784 126 }
5785
5786
2/2
✓ Branch 0 taken 1307 times.
✓ Branch 1 taken 130 times.
1437 for(int32_t i=0; i<warprings; i++)
5787 {
5788 // See above comment on the `warprings` range check.
5789 1307 bool keepdata = i < NUM_WARP_RINGS;
5790
5791
2/2
✓ Branch 0 taken 11539 times.
✓ Branch 1 taken 1307 times.
12846 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5792 {
5793
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9747 times.
11539 if(s_version <= 3)
5794 {
5795
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5796 {
5797 return qe_invalid;
5798 }
5799
5800
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5801 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5802 1792 }
5803 else
5804 {
5805 word tempword;
5806
1/2
✓ Branch 0 taken 9747 times.
✗ Branch 1 not taken.
9747 if(!p_igetw(&tempword,f))
5807 {
5808 return qe_invalid;
5809 }
5810
5811
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9234 times.
9747 if (keepdata)
5812 9234 temp_misc.warp[i].dmap[j] = tempword;
5813 }
5814 11539 }
5815
5816
2/2
✓ Branch 0 taken 11539 times.
✓ Branch 1 taken 1307 times.
12846 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5817 {
5818
1/2
✓ Branch 0 taken 11539 times.
✗ Branch 1 not taken.
11539 if(!p_getc(&tempbyte,f))
5819 {
5820 return qe_invalid;
5821 }
5822
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 10354 times.
11539 if (keepdata)
5823 10354 temp_misc.warp[i].scr[j] = tempbyte;
5824 11539 }
5825
5826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1307 times.
1307 if(!p_getc(&tempbyte,f))
5827 {
5828 return qe_invalid;
5829 }
5830
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1166 times.
1307 if (keepdata)
5831 1166 temp_misc.warp[i].size = tempbyte;
5832
5833
2/2
✓ Branch 0 taken 1275 times.
✓ Branch 1 taken 32 times.
1307 if(Header->zelda_version < 0x193)
5834 {
5835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5836 {
5837 return qe_invalid;
5838 }
5839 32 }
5840 1307 }
5841
5842 //palette cycles
5843
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5844 {
5845
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5846 {
5847
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5848 {
5849 3072 temp_misc.cycles[i][j].first=0;
5850 3072 temp_misc.cycles[i][j].count=0;
5851 3072 temp_misc.cycles[i][j].speed=0;
5852 3072 }
5853 1024 }
5854
5855
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5856 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5857 {
5858 4 palcycles=16;
5859 4 }
5860
5861
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5862 {
5863
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5864 {
5865
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5866 {
5867 return qe_invalid;
5868 }
5869
5870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5871 {
5872 return qe_invalid;
5873 }
5874
5875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5876 {
5877 return qe_invalid;
5878 }
5879 192 }
5880 64 }
5881 4 }
5882
5883 //Wind warps are now just another warp ring.
5884
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version <= 5)
5885 {
5886
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5887 {
5888
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5889 {
5890 return qe_invalid;
5891 }
5892 12 }
5893
5894
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5895 {
5896 return qe_invalid;
5897 }
5898
5899
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5900 {
5901
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5902 {
5903
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5904 {
5905 return qe_invalid;
5906 }
5907
5908 135 temp_misc.warp[8].dmap[i]=tempbyte;
5909 135 }
5910 else
5911 {
5912 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5913 {
5914 return qe_invalid;
5915 }
5916 }
5917
5918
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5919 {
5920 return qe_invalid;
5921 }
5922
5923 135 temp_misc.warp[8].size = 9;
5924
5925
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5926 {
5927 if(!p_getc(&tempbyte,f))
5928 {
5929 return qe_invalid;
5930 }
5931 }
5932 135 }
5933 16 }
5934
5935
5936 //triforce pieces
5937
2/2
✓ Branch 0 taken 1040 times.
✓ Branch 1 taken 130 times.
1170 for(int32_t i=0; i<triforces; i++)
5938 {
5939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1040 times.
1040 if(!p_getc(&temp_misc.triforce[i],f))
5940 {
5941 return qe_invalid;
5942 }
5943 1040 }
5944
5945 //misc color data
5946
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<3)
5947 {
5948
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5949 {
5950 return qe_invalid;
5951 }
5952
5953
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5954 {
5955 return qe_invalid;
5956 }
5957
5958
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5959 {
5960 return qe_invalid;
5961 }
5962
5963
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5964 {
5965 return qe_invalid;
5966 }
5967
5968
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5969 {
5970 return qe_invalid;
5971 }
5972
5973
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5974 {
5975 return qe_invalid;
5976 }
5977
5978
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
5979 {
5980 return qe_invalid;
5981 }
5982
5983
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
5984 {
5985 return qe_invalid;
5986 }
5987
5988
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
5989 {
5990 return qe_invalid;
5991 }
5992
5993
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
5994 {
5995 return qe_invalid;
5996 }
5997
5998
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5999 {
6000 return qe_invalid;
6001 }
6002
6003
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
6004 {
6005 return qe_invalid;
6006 }
6007
6008
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
6009 {
6010 return qe_invalid;
6011 }
6012
6013
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
6014 {
6015 return qe_invalid;
6016 }
6017
6018
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
6019 {
6020 return qe_invalid;
6021 }
6022
6023
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
6024 {
6025 return qe_invalid;
6026 }
6027
6028
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
6029 {
6030 return qe_invalid;
6031 }
6032
6033
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
6034 {
6035 return qe_invalid;
6036 }
6037
6038
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
6039 {
6040 return qe_invalid;
6041 }
6042
6043
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
6044 {
6045 return qe_invalid;
6046 }
6047
6048
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
6049 {
6050 return qe_invalid;
6051 }
6052
6053
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
6054 {
6055 return qe_invalid;
6056 }
6057
6058
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6059 {
6060 return qe_invalid;
6061 }
6062
6063
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6064 {
6065 return qe_invalid;
6066 }
6067
6068
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6069 {
6070 return qe_invalid;
6071 }
6072
6073
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6074 {
6075 return qe_invalid;
6076 }
6077
6078
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6079 {
6080 return qe_invalid;
6081 }
6082
6083 16 temp_misc.colors.msgtext = 0x01;
6084
6085
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6086 {
6087
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6088 {
6089
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6090 {
6091 return qe_invalid;
6092 }
6093 28 }
6094 4 }
6095
6096
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6097 {
6098 for(int32_t i=0; i<256; i++)
6099 {
6100 if(!p_getc(&tempbyte,f))
6101 {
6102 return qe_invalid;
6103 }
6104 }
6105 }
6106
6107
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6108 {
6109 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6110 {
6111 return qe_invalid;
6112 }
6113 }
6114
6115 //save game icons
6116
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6118 {
6119 4 icons=3;
6120 4 }
6121
6122
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6123 {
6124
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6125 {
6126 return qe_invalid;
6127 }
6128 60 }
6129 16 }
6130
6131
2/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
130 if((Header->zelda_version < 0x192)||
6132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6133 {
6134 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6135
6136 4 return 0;
6137 }
6138
6139 //pond information
6140
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(Header->zelda_version < 0x193)
6141 {
6142 if((Header->zelda_version == 0x192)&&(Header->build<146))
6143 {
6144 pondsize=25;
6145 }
6146
6147 for(int32_t i=0; i<ponds; i++)
6148 {
6149 for(int32_t j=0; j<pondsize; j++)
6150 {
6151 if(!p_getc(&tempbyte,f))
6152 {
6153 return qe_invalid;
6154
6155 }
6156 }
6157 }
6158 }
6159
6160 //end string
6161
1/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if((Header->zelda_version < 0x192)||
6162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6163 {
6164 if(!p_getc(&tempbyte,f))
6165 {
6166 return qe_invalid;
6167 }
6168
6169 temp_misc.endstring=tempbyte;
6170
6171 if(!p_getc(&tempbyte,f))
6172 {
6173 return qe_invalid;
6174 }
6175 }
6176 else
6177 {
6178
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&temp_misc.endstring,f))
6179 {
6180 return qe_invalid;
6181 }
6182 }
6183
6184 //expansion
6185
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(Header->zelda_version < 0x193)
6186 {
6187 if((Header->zelda_version == 0x192)&&(Header->build<73))
6188 {
6189 expansionsize=99*2;
6190 }
6191
6192 for(int32_t i=0; i<expansionsize; i++)
6193 {
6194 if(!p_getc(&tempbyte,f))
6195 {
6196 return qe_invalid;
6197 }
6198 }
6199 }
6200 //shops v8
6201
6202
6203
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if(s_version >= 8)
6204 {
6205
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 37 times.
597 for(int32_t i=0; i<shops; i++)
6206 {
6207
2/2
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 560 times.
2240 for(int32_t j=0; j<3; j++)
6208 {
6209
1/2
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
1680 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6210 return qe_invalid;
6211 1680 }
6212 560 }
6213 37 }
6214
6215 126 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6216 126 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6217 126 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6218
6219 //v9 includes quest misc[32]
6220
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 37 times.
126 if(s_version >= 9)
6221 {
6222
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 37 times.
1221 for ( int32_t q = 0; q < 32; q++ )
6223 {
6224
1/2
✓ Branch 0 taken 1184 times.
✗ Branch 1 not taken.
1184 if(!p_igetl(&temp_misc.questmisc[q],f))
6225 return qe_invalid;
6226 1184 }
6227
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 37 times.
1221 for ( int32_t q = 0; q < 32; q++ )
6228 {
6229
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 1184 times.
152736 for ( int32_t j = 0; j < 128; j++ )
6230
1/2
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
151552 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6231 return qe_invalid;
6232 1184 }
6233 37 }
6234
6235
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version >= 11 )
6236 {
6237
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6238 return qe_invalid;
6239 37 }
6240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6241 {
6242 89 temp_misc.zscript_last_compiled_version = -1;
6243 89 }
6244
6245 126 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6246
6247
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version >= 12)
6248 {
6249 byte spr;
6250
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t q = 0; q < sprMAX; ++q)
6251 {
6252
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_getc(&spr,f))
6253 return qe_invalid;
6254 9472 temp_misc.sprites[q] = spr;
6255 9472 }
6256 37 }
6257 else
6258 {
6259 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6260 //temp_misc.sprites[sprFALL] = ;
6261 }
6262
6263
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version >= 13)
6264 {
6265
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 37 times.
2405 for(size_t q = 0; q < 64; ++q)
6266 {
6267 2368 bottletype* bt = &(temp_misc.bottle_types[q]);
6268
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6269 return qe_invalid;
6270
2/2
✓ Branch 0 taken 7104 times.
✓ Branch 1 taken 2368 times.
9472 for(size_t j = 0; j < 3; ++j)
6271 {
6272
1/2
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
7104 if (!p_getc(&(bt->counter[j]), f))
6273 return qe_invalid;
6274
1/2
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
7104 if (!p_igetw(&(bt->amount[j]), f))
6275 return qe_invalid;
6276 7104 }
6277
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 if (!p_getc(&(bt->flags), f))
6278 return qe_invalid;
6279
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 if (!p_getc(&(bt->next_type), f))
6280 return qe_invalid;
6281 2368 }
6282
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(size_t q = 0; q < 256; ++q)
6283 {
6284 9472 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6285
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6286 return qe_invalid;
6287
2/2
✓ Branch 0 taken 28416 times.
✓ Branch 1 taken 9472 times.
37888 for(size_t j = 0; j < 3; ++j)
6288 {
6289
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_getc(&(bst->fill[j]), f))
6290 return qe_invalid;
6291
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_igetw(&(bst->comb[j]), f))
6292 return qe_invalid;
6293
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_getc(&(bst->cset[j]), f))
6294 return qe_invalid;
6295
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_igetw(&(bst->price[j]), f))
6296 return qe_invalid;
6297
1/2
✓ Branch 0 taken 28416 times.
✗ Branch 1 not taken.
28416 if (!p_igetw(&(bst->str[j]), f))
6298 return qe_invalid;
6299 28416 }
6300 9472 }
6301 37 }
6302 else
6303 {
6304
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6305 5696 temp_misc.bottle_types[q].clear();
6306
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6307 22784 temp_misc.bottle_shop_types[q].clear();
6308 }
6309
6310
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version >= 14)
6311 {
6312 byte msfx;
6313
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t q = 0; q < sfxMAX; ++q)
6314 {
6315
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_getc(&msfx,f))
6316 return qe_invalid;
6317 9472 temp_misc.miscsfx[q] = msfx;
6318 9472 }
6319 37 }
6320 else
6321 {
6322 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6323 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6324 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6325 }
6326
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
126 if(s_version < 15)
6327 {
6328 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6329 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6330 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6331 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6332 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6333 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6334 89 }
6335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(s_version < 16)
6336 {
6337 126 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6338 126 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6339 126 }
6340
6341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (!should_skip)
6342 126 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6343
6344 126 return 0;
6345 130 }
6346
6347 extern char *item_string[MAXITEMS];
6348 extern const char *old_item_string[iLast];
6349 extern char *weapon_string[MAXWPNS];
6350 extern const char *old_weapon_string[wLast];
6351
6352 130 int32_t readitems(PACKFILE *f, word version, word build)
6353 {
6354
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6355
6356 byte padding;
6357 int32_t dummy;
6358 130 word items_to_read=MAXITEMS;
6359 itemdata tempitem;
6360 130 word s_version=0, s_cversion=0;
6361 word dummy_word;
6362
6363
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(version < 0x186)
6364 {
6365 items_to_read=64;
6366 }
6367
6368
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(version > 0x192)
6369 {
6370 126 items_to_read=0;
6371
6372 //section version info
6373
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
6374 {
6375 return qe_invalid;
6376 }
6377
6378 126 FFCore.quest_format[vItems] = s_version;
6379
6380 //al_trace("Items version %d\n", s_version);
6381
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_cversion,f))
6382 {
6383 return qe_invalid;
6384 }
6385
6386 //section size
6387
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
6388 {
6389 return qe_invalid;
6390 }
6391
6392 //finally... section data
6393
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&items_to_read,f))
6394 {
6395 return qe_invalid;
6396 }
6397
6398
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6399 {
6400 return qe_invalid;
6401 }
6402 126 }
6403
6404
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version>1)
6405 {
6406
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<items_to_read; i++)
6407 {
6408 char tempname[64];
6409
6410
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!pfread(tempname, 64, f))
6411 {
6412 return qe_invalid;
6413 }
6414
6415 29184 item_string[i][0] = '\0';
6416 29184 strncat(item_string[i], tempname, 64 - 1);
6417 29184 }
6418 114 }
6419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if (!should_skip)
6420 {
6421
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6422 {
6423 4096 reset_itemname(i);
6424 4096 }
6425 16 }
6426
6427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (!should_skip)
6428
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<MAXITEMS; i++)
6429 {
6430 33280 itemdata& id = itemsbuf[i];
6431 33280 memset(&id, 0, sizeof(itemdata));
6432 33280 id.count=-1;
6433 33280 id.playsound=WAV_SCALE;
6434 33280 reset_itembuf(&id,i);
6435 33410 }
6436
6437
2/2
✓ Branch 0 taken 31048 times.
✓ Branch 1 taken 130 times.
31178 for(int32_t i=0; i<items_to_read; i++)
6438 {
6439 31048 memset(&tempitem, 0, sizeof(itemdata));
6440 31048 reset_itembuf(&tempitem,i);
6441
6442
6443
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 21576 times.
31048 if ( s_version > 35 ) //expanded tiles
6444 {
6445
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.tile,f))
6446 {
6447 return qe_invalid;
6448 }
6449 9472 }
6450 else
6451 {
6452
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6453 {
6454 return qe_invalid;
6455 }
6456 }
6457
6458
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.misc_flags,f))
6459 {
6460 return qe_invalid;
6461 }
6462
6463
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.csets,f))
6464 {
6465 return qe_invalid;
6466 }
6467
6468
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.frames,f))
6469 {
6470 return qe_invalid;
6471 }
6472
6473
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.speed,f))
6474 {
6475 return qe_invalid;
6476 }
6477
6478
1/2
✓ Branch 0 taken 31048 times.
✗ Branch 1 not taken.
31048 if(!p_getc(&tempitem.delay,f))
6479 {
6480 return qe_invalid;
6481 }
6482
6483
2/2
✓ Branch 0 taken 30024 times.
✓ Branch 1 taken 1024 times.
31048 if(version < 0x193)
6484 {
6485
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6486 {
6487 return qe_invalid;
6488 }
6489
6490
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6491 {
6492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if (should_skip)
6493 continue;
6494
6495
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6496 {
6497 case iShield:
6498 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6499 4 break;
6500
6501 case iMShield:
6502 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6503 4 break;
6504
6505 default:
6506 1016 tempitem.ltm=0;
6507 1016 break;
6508 }
6509
6510 1024 tempitem.count=-1;
6511 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6512 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6513 1024 tempitem.family=0xFF;
6514 1024 tempitem.playsound=WAV_SCALE;
6515 1024 reset_itembuf(&tempitem,i);
6516
6517 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6518
6519 1024 continue;
6520 }
6521 }
6522
6523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30024 times.
30024 if(!p_igetl(&tempitem.ltm,f))
6524 {
6525 return qe_invalid;
6526 }
6527
6528
1/2
✓ Branch 0 taken 30024 times.
✗ Branch 1 not taken.
30024 if(version < 0x193)
6529 {
6530 for(int32_t q=0; q<12; q++)
6531 {
6532 if(!p_getc(&padding,f))
6533 {
6534 return qe_invalid;
6535 }
6536 }
6537 }
6538
6539
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 840 times.
30024 if(s_version>1)
6540 {
6541
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 19712 times.
29184 if ( s_version >= 31 )
6542 {
6543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.family,f))
6544 {
6545 return qe_invalid;
6546 }
6547 9472 }
6548 else
6549 {
6550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6551 {
6552 return qe_invalid;
6553 }
6554 }
6555
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version < 16)
6556 if(tempitem.family == 0xFF)
6557 tempitem.family = itype_misc;
6558
6559
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.fam_type,f))
6560 {
6561 return qe_invalid;
6562 }
6563
6564
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version>5)
6565 {
6566
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 19712 times.
29184 if(s_version>=31)
6567 {
6568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.power,f))
6569 {
6570 return qe_invalid;
6571 }
6572 9472 }
6573 else
6574 {
6575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6576 {
6577 return qe_invalid;
6578 }
6579 }
6580
6581 //converted flags from 16b to 32b -Z
6582
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version < 41 )
6583 {
6584
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6585 {
6586 return qe_invalid;
6587 }
6588 19712 }
6589 else
6590 {
6591
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.flags,f))
6592 {
6593 return qe_invalid;
6594 }
6595 }
6596 29184 }
6597 else
6598 {
6599 //tempitem.power = tempitem.fam_type;
6600 char tempchar;
6601
6602 if(!p_getc(&tempchar,f))
6603 {
6604 return qe_invalid;
6605 }
6606
6607 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6608 }
6609
6610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetw(&tempitem.script,f))
6611 {
6612 return qe_invalid;
6613 }
6614
6615
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version<=3)
6616 {
6617 if(tempitem.script > NUMSCRIPTITEM)
6618 {
6619 tempitem.script = 0;
6620 }
6621 }
6622
6623
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.count,f))
6624 {
6625 return qe_invalid;
6626 }
6627
6628
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetw(&tempitem.amount,f))
6629 {
6630 return qe_invalid;
6631 }
6632
6633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetw(&tempitem.collect_script,f))
6634 {
6635 return qe_invalid;
6636 }
6637
6638
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version<=3)
6639 {
6640 if(tempitem.collect_script > NUMSCRIPTITEM)
6641 {
6642 tempitem.collect_script = 0;
6643 }
6644 }
6645
6646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetw(&tempitem.setmax,f))
6647 {
6648 return qe_invalid;
6649 }
6650
6651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetw(&tempitem.max,f))
6652 {
6653 return qe_invalid;
6654 }
6655
6656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_getc(&tempitem.playsound,f))
6657 {
6658 return qe_invalid;
6659 }
6660
6661
2/2
✓ Branch 0 taken 233472 times.
✓ Branch 1 taken 29184 times.
262656 for(int32_t j=0; j<8; j++)
6662 {
6663
1/2
✓ Branch 0 taken 233472 times.
✗ Branch 1 not taken.
233472 if(!p_igetl(&tempitem.initiald[j],f))
6664 {
6665 return qe_invalid;
6666 }
6667 233472 }
6668
6669
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 29184 times.
87552 for(int32_t j=0; j<2; j++)
6670 {
6671
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&tempitem.initiala[j],f))
6672 {
6673 return qe_invalid;
6674 }
6675 58368 }
6676
6677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version>4)
6678 {
6679
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version>5)
6680 {
6681
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn,f))
6682 {
6683 return qe_invalid;
6684 }
6685
6686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_getc(&tempitem.wpn2,f))
6687 {
6688 return qe_invalid;
6689 }
6690
6691
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn3,f))
6692 {
6693 return qe_invalid;
6694 }
6695
6696
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn4,f))
6697 {
6698 return qe_invalid;
6699 }
6700
6701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version>=15)
6702 {
6703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_getc(&tempitem.wpn5,f))
6704 {
6705 return qe_invalid;
6706 }
6707
6708
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn6,f))
6709 {
6710 return qe_invalid;
6711 }
6712
6713
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn7,f))
6714 {
6715 return qe_invalid;
6716 }
6717
6718
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn8,f))
6719 {
6720 return qe_invalid;
6721 }
6722
6723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_getc(&tempitem.wpn9,f))
6724 {
6725 return qe_invalid;
6726 }
6727
6728
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.wpn10,f))
6729 {
6730 return qe_invalid;
6731 }
6732 29184 }
6733
6734
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.pickup_hearts,f))
6735 {
6736 return qe_invalid;
6737 }
6738
6739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version<15)
6740 {
6741 if(!p_igetw(&dummy_word,f))
6742 {
6743 return qe_invalid;
6744 }
6745
6746 tempitem.misc1=dummy_word;
6747
6748 if(!p_igetw(&dummy_word,f))
6749 {
6750 return qe_invalid;
6751 }
6752
6753 tempitem.misc2=dummy_word;
6754 }
6755 else
6756 {
6757
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc1,f))
6758 {
6759 return qe_invalid;
6760 }
6761
6762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetl(&tempitem.misc2,f))
6763 {
6764 return qe_invalid;
6765 }
6766
6767 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6768
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(s_version<24)
6769 {
6770 if(tempitem.family==itype_shield)
6771 {
6772 tempitem.misc1|=shSCRIPT;
6773 }
6774 }
6775 }
6776
6777
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if(s_version < 53)
6778 {
6779 byte tempbyte;
6780
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6781 {
6782 return qe_invalid;
6783 }
6784 19712 tempitem.cost_amount[0] = tempbyte;
6785 19712 }
6786 else
6787 {
6788
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for(auto q = 0; q < 2; ++q)
6789 {
6790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18944 times.
18944 if(!p_igetw(&tempitem.cost_amount[q],f))
6791 {
6792 return qe_invalid;
6793 }
6794 18944 }
6795 }
6796 29184 }
6797 else
6798 {
6799 char tempchar;
6800
6801 if(!p_getc(&tempchar,f))
6802 {
6803 return qe_invalid;
6804 }
6805
6806 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6807 }
6808
6809 // June 2007: more misc. attributes
6810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version>=12)
6811 {
6812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(s_version<15)
6813 {
6814 if(!p_igetw(&dummy_word,f))
6815 {
6816 return qe_invalid;
6817 }
6818
6819 tempitem.misc3=dummy_word;
6820
6821 if(!p_igetw(&dummy_word,f))
6822 {
6823 return qe_invalid;
6824 }
6825
6826 tempitem.misc4=dummy_word;
6827 }
6828 else
6829 {
6830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetl(&tempitem.misc3,f))
6831 {
6832 return qe_invalid;
6833 }
6834
6835
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc4,f))
6836 {
6837 return qe_invalid;
6838 }
6839
6840
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc5,f))
6841 {
6842 return qe_invalid;
6843 }
6844
6845
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc6,f))
6846 {
6847 return qe_invalid;
6848 }
6849
6850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetl(&tempitem.misc7,f))
6851 {
6852 return qe_invalid;
6853 }
6854
6855
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc8,f))
6856 {
6857 return qe_invalid;
6858 }
6859
6860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29184 times.
29184 if(!p_igetl(&tempitem.misc9,f))
6861 {
6862 return qe_invalid;
6863 }
6864
6865
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_igetl(&tempitem.misc10,f))
6866 {
6867 return qe_invalid;
6868 }
6869 }
6870
6871
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!p_getc(&tempitem.usesound,f))
6872 {
6873 return qe_invalid;
6874 }
6875
6876
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 19712 times.
29184 if(s_version >= 49)
6877 {
6878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_getc(&tempitem.usesound2,f))
6879 {
6880 return qe_invalid;
6881 }
6882 9472 }
6883 19712 else tempitem.usesound2 = 0;
6884
6885
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
29184 if(s_version < 50 && tempitem.family == itype_mirror)
6886 {
6887 //Split continue/dmap warp effect/sfx, port for old
6888 tempitem.misc2 = tempitem.misc1;
6889 tempitem.usesound2 = tempitem.usesound;
6890 }
6891 29184 }
6892 29184 }
6893
6894
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6895 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_getc(&tempitem.useweapon,f))
6897 {
6898 return qe_invalid;
6899 }
6900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_getc(&tempitem.usedefence,f))
6901 {
6902 return qe_invalid;
6903 }
6904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weaprange,f))
6905 {
6906 return qe_invalid;
6907 }
6908
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weapduration,f))
6909 {
6910 return qe_invalid;
6911 }
6912
2/2
✓ Branch 0 taken 94720 times.
✓ Branch 1 taken 9472 times.
104192 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6913 {
6914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94720 times.
94720 if(!p_igetl(&tempitem.weap_pattern[q],f))
6915 {
6916 return qe_invalid;
6917 }
6918 94720 }
6919 9472 }
6920
6921
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6922 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6923
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.duplicates,f))
6924 {
6925 return qe_invalid;
6926 }
6927
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 9472 times.
85248 for ( int32_t q = 0; q < INITIAL_D; q++ )
6928 {
6929
1/2
✓ Branch 0 taken 75776 times.
✗ Branch 1 not taken.
75776 if(!p_igetl(&tempitem.weap_initiald[q],f))
6930 {
6931 return qe_invalid;
6932 }
6933 75776 }
6934
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for ( int32_t q = 0; q < INITIAL_A; q++ )
6935 {
6936
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.weap_initiala[q],f))
6937 {
6938 return qe_invalid;
6939 }
6940 18944 }
6941
6942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_getc(&tempitem.drawlayer,f))
6943 {
6944 return qe_invalid;
6945 }
6946
6947
6948
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.hxofs,f))
6949 {
6950 return qe_invalid;
6951 }
6952
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.hyofs,f))
6953 {
6954 return qe_invalid;
6955 }
6956
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.hxsz,f))
6957 {
6958 return qe_invalid;
6959 }
6960
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.hysz,f))
6961 {
6962 return qe_invalid;
6963 }
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.hzsz,f))
6965 {
6966 return qe_invalid;
6967 }
6968
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.xofs,f))
6969 {
6970 return qe_invalid;
6971 }
6972
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.yofs,f))
6973 {
6974 return qe_invalid;
6975 }
6976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_hxofs,f))
6977 {
6978 return qe_invalid;
6979 }
6980
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weap_hyofs,f))
6981 {
6982 return qe_invalid;
6983 }
6984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_hxsz,f))
6985 {
6986 return qe_invalid;
6987 }
6988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_hysz,f))
6989 {
6990 return qe_invalid;
6991 }
6992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_hzsz,f))
6993 {
6994 return qe_invalid;
6995 }
6996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weap_xofs,f))
6997 {
6998 return qe_invalid;
6999 }
7000
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weap_yofs,f))
7001 {
7002 return qe_invalid;
7003 }
7004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetw(&tempitem.weaponscript,f))
7005 {
7006 return qe_invalid;
7007 }
7008
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.wpnsprite,f))
7009 {
7010 return qe_invalid;
7011 }
7012 9472 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
7013
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for(auto q = 0; q < num_cost_tmr; ++q)
7014 {
7015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18944 times.
18944 if(!p_igetl(&tempitem.magiccosttimer[q],f))
7016 {
7017 return qe_invalid;
7018 }
7019 18944 }
7020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 for(auto q = num_cost_tmr; q < 2; ++q)
7021 tempitem.magiccosttimer[q] = 0;
7022 9472 }
7023
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7024 {
7025 //Item Size FLags, TileWidth, TileHeight
7026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.overrideFLAGS,f))
7027 {
7028 return qe_invalid;
7029 }
7030
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.tilew,f))
7031 {
7032 return qe_invalid;
7033 }
7034
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.tileh,f))
7035 {
7036 return qe_invalid;
7037 }
7038 9472 }
7039
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 29 ) //! More new vars.
7040 {
7041 //Item Size FLags, TileWidth, TileHeight
7042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
7043 {
7044 return qe_invalid;
7045 }
7046
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weap_tilew,f))
7047 {
7048 return qe_invalid;
7049 }
7050
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.weap_tileh,f))
7051 {
7052 return qe_invalid;
7053 }
7054 9472 }
7055
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 30 ) //! More new vars.
7056 {
7057 //Pickup Type
7058
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempitem.pickup,f))
7059 {
7060 return qe_invalid;
7061 }
7062 9472 }
7063
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 32 ) //! More new vars.
7064 {
7065 //Pickup Type
7066
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetw(&tempitem.pstring,f))
7067 {
7068 return qe_invalid;
7069 }
7070 9472 }
7071
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 33 ) //! More new vars.
7072 {
7073 //Pickup Type
7074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(!p_igetw(&tempitem.pickup_string_flags,f))
7075 {
7076 return qe_invalid;
7077 }
7078 9472 }
7079
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 34 ) //! cost counter
7080 {
7081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9472 times.
9472 if(s_version < 53)
7082 {
7083 if(!p_getc(&tempitem.cost_counter[0],f))
7084 {
7085 return qe_invalid;
7086 }
7087 }
7088 else
7089 {
7090
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for(auto q = 0; q < 2; ++q)
7091 {
7092
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.cost_counter[q],f))
7093 {
7094 return qe_invalid;
7095 }
7096 18944 }
7097 }
7098 9472 }
7099
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 44 ) //! sprite scripts
7100 {
7101
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 9472 times.
85248 for ( int32_t q = 0; q < 8; q++ )
7102 {
7103
2/2
✓ Branch 0 taken 4925440 times.
✓ Branch 1 taken 75776 times.
5001216 for ( int32_t w = 0; w < 65; w++ )
7104 {
7105
1/2
✓ Branch 0 taken 4925440 times.
✗ Branch 1 not taken.
4925440 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7106 {
7107 return qe_invalid;
7108 }
7109 4925440 }
7110
2/2
✓ Branch 0 taken 4925440 times.
✓ Branch 1 taken 75776 times.
5001216 for ( int32_t w = 0; w < 65; w++ )
7111 {
7112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4925440 times.
4925440 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7113 {
7114 return qe_invalid;
7115 }
7116 4925440 }
7117
2/2
✓ Branch 0 taken 4925440 times.
✓ Branch 1 taken 75776 times.
5001216 for ( int32_t w = 0; w < 65; w++ )
7118 {
7119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4925440 times.
4925440 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7120 {
7121 return qe_invalid;
7122 }
7123 4925440 }
7124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75776 times.
75776 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7125 {
7126 return qe_invalid;
7127 }
7128
7129 75776 }
7130
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 9472 times.
28416 for ( int32_t q = 0; q < 2; q++ )
7131 {
7132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18944 times.
18944 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7133 {
7134 return qe_invalid;
7135 }
7136 18944 }
7137 //Pickup Type
7138
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetw(&tempitem.sprite_script,f))
7139 {
7140 return qe_invalid;
7141 }
7142 9472 }
7143
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9472 times.
29184 if ( s_version >= 48 ) //! pickup flags
7144 {
7145
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_getc(&(tempitem.pickupflag),f))
7146 {
7147 return qe_invalid;
7148 }
7149 9472 }
7150
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 8192 times.
29184 if ( s_version >= 57 )
7151 {
7152 8192 std::string str;
7153
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getcstr(&str,f))
7154 return qe_invalid;
7155 8192 strncpy(tempitem.display_name,str.c_str(),255);
7156
1/3
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
8192 }
7157 29184 }
7158 else
7159 {
7160 840 tempitem.count=-1;
7161 840 tempitem.family=itype_misc;
7162 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7163 840 tempitem.playsound=WAV_SCALE;
7164 840 reset_itembuf(&tempitem,i);
7165 }
7166
7167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30024 times.
30024 if (!should_skip)
7168 {
7169
1/2
✓ Branch 0 taken 30024 times.
✗ Branch 1 not taken.
30024 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7170 {
7171 tempitem.script = 0;
7172 tempitem.weaponscript = 0;
7173 for(int q = 0; q < 8; ++q)
7174 {
7175 tempitem.initiald[q] = 0;
7176 tempitem.weap_initiald[q] = 0;
7177 }
7178 }
7179 30024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7180 30024 }
7181 30024 }
7182
7183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (should_skip)
7184 return 0;
7185
7186 //////////////////////////////////////////////////////
7187 // Now do any updates because of new item additions
7188 // (These can't be done above because items_to_read
7189 // might be too low.)
7190 //////////////////////////////////////////////////////
7191
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<MAXITEMS; i++)
7192 {
7193 33280 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7194
7195 //Account for older quests that didn't have an actual item for the used letter
7196
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29184 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33280 if(s_version < 2 && i==iLetterUsed)
7197 {
7198 16 reset_itembuf(&tempitem, iLetterUsed);
7199 16 strcpy(item_string[i],old_item_string[i]);
7200 16 tempitem.tile = itemsbuf[iLetter].tile;
7201 16 tempitem.csets = itemsbuf[iLetter].csets;
7202 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7203 16 tempitem.frames = itemsbuf[iLetter].frames;
7204 16 tempitem.speed = itemsbuf[iLetter].speed;
7205 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7206 16 }
7207
7208
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 3)
7209 {
7210
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7211 {
7212 case iRocsFeather:
7213 case iHoverBoots:
7214 case iSpinScroll:
7215 case iL2SpinScroll:
7216 case iCrossScroll:
7217 case iQuakeScroll:
7218 case iL2QuakeScroll:
7219 case iWhispRing:
7220 case iL2WhispRing:
7221 case iChargeRing:
7222 case iL2ChargeRing:
7223 case iPerilScroll:
7224 case iWalletL3:
7225 case iQuiverL4:
7226 case iBombBagL4:
7227 case iBracelet:
7228 case iL2Bracelet:
7229 case iOldGlove:
7230 case iL2Ladder:
7231 case iWealthMedal:
7232 case iL2WealthMedal:
7233 case iL3WealthMedal:
7234 352 reset_itembuf(&tempitem, i);
7235 352 strcpy(item_string[i],old_item_string[i]);
7236 352 break;
7237
7238 case iSShield:
7239 16 reset_itembuf(&tempitem, i);
7240 16 strcpy(item_string[i],old_item_string[i]);
7241 16 strcpy(item_string[iShield],old_item_string[iShield]);
7242 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7243 16 break;
7244 }
7245 4096 }
7246
7247
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 5)
7248 {
7249
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7250 {
7251 case iHeartRing:
7252 case iL2HeartRing:
7253 case iL3HeartRing:
7254 case iMagicRing:
7255 case iL2MagicRing:
7256 case iL3MagicRing:
7257 case iL4MagicRing:
7258 112 reset_itembuf(&tempitem, i);
7259 112 strcpy(item_string[i],old_item_string[i]);
7260 112 break;
7261 }
7262 4096 }
7263
7264
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7265 {
7266
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7267 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7268
7269
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 64 times.
✓ Branch 7 taken 3376 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 16 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7270 {
7271 case iTriforce:
7272 16 tempitem.fam_type=1;
7273 16 break;
7274
7275 case iBigTri:
7276 16 tempitem.fam_type=0;
7277 16 break;
7278
7279 case iBombs:
7280 16 tempitem.fam_type=i_bomb;
7281 16 tempitem.power=4;
7282 16 tempitem.wpn=wBOMB;
7283 16 tempitem.wpn2=wBOOM;
7284 16 tempitem.misc1 = 50;
7285
7286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7287
7288 16 break;
7289
7290 case iSBomb:
7291 16 tempitem.fam_type=i_sbomb;
7292 16 tempitem.power=16;
7293 16 tempitem.wpn=wSBOMB;
7294 16 tempitem.wpn2=wSBOOM;
7295 16 tempitem.misc1 = 50;
7296
7297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7298
7299 16 break;
7300
7301 case iBook:
7302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7303 tempitem.wpn = wFIREMAGIC;
7304
7305 16 break;
7306
7307 case iSArrow:
7308 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7309 16 tempitem.power=4;
7310 16 tempitem.flags|=ITEM_GAMEDATA;
7311 16 tempitem.wpn=wSARROW;
7312 16 break;
7313
7314 case iGArrow:
7315 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7316 16 tempitem.power=8;
7317 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7318 16 tempitem.wpn=wGARROW;
7319 16 break;
7320
7321 case iBrang:
7322 16 tempitem.power=0;
7323 16 tempitem.wpn=wBRANG;
7324 16 tempitem.misc1=36;
7325 16 break;
7326
7327 case iMBrang:
7328 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7329 16 tempitem.power=0;
7330 16 tempitem.wpn=wMBRANG;
7331 16 break;
7332
7333 case iFBrang:
7334 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7335 16 tempitem.power=2;
7336 16 tempitem.wpn=wFBRANG;
7337 16 break;
7338
7339 case iBoots:
7340 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7341 16 tempitem.power=7;
7342 16 break;
7343
7344 case iWand:
7345 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7346 16 tempitem.power=2;
7347 16 tempitem.wpn=wWAND;
7348 16 tempitem.wpn3=wMAGIC;
7349 16 break;
7350
7351 case iBCandle:
7352 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7353 16 tempitem.power=1;
7354 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7355 16 tempitem.wpn3=wFIRE;
7356 16 break;
7357
7358 case iRCandle:
7359 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7360 16 tempitem.power=1;
7361 16 tempitem.wpn3=wFIRE;
7362 16 break;
7363
7364 case iSword:
7365 16 tempitem.power=1;
7366 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7367 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7368 16 tempitem.wpn2=wSWORDSLASH;
7369 16 break;
7370
7371 case iWSword:
7372 16 tempitem.power=2;
7373 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7374 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7375 16 tempitem.wpn2=wWSWORDSLASH;
7376 16 break;
7377
7378 case iMSword:
7379 16 tempitem.power=4;
7380 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7381 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7382 16 tempitem.wpn2=wMSWORDSLASH;
7383 16 break;
7384
7385 case iXSword:
7386 16 tempitem.power=8;
7387 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7388 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7389 16 tempitem.wpn2=wXSWORDSLASH;
7390 16 break;
7391
7392 case iDivineProtection:
7393 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7394 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7395 16 tempitem.wpn=wDIVINEPROTECTION1A;
7396 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7397 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7398 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7399 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7400 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7401 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7402 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7403 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7404 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7405 16 tempitem.misc1=512;
7406 16 tempitem.cost_amount[0]=64;
7407 16 break;
7408
7409 case iLens:
7410 16 tempitem.misc1=60;
7411 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7412 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7413 16 break;
7414
7415 case iArrow:
7416 16 tempitem.power=2;
7417 16 tempitem.wpn=wARROW;
7418 16 break;
7419
7420 case iHoverBoots:
7421 16 tempitem.misc1=45;
7422 16 tempitem.wpn=iwHover;
7423 16 break;
7424
7425 case iDivineFire:
7426 16 tempitem.power=8;
7427 16 tempitem.wpn=wDIVINEFIRE1A;
7428 16 tempitem.wpn2=wDIVINEFIRE1B;
7429 16 tempitem.wpn3=wDIVINEFIRES1A;
7430 16 tempitem.wpn4=wDIVINEFIRES1B;
7431 16 tempitem.misc1 = 32;
7432 16 tempitem.misc2 = 200;
7433 16 tempitem.cost_amount[0]=32;
7434 16 break;
7435
7436 case iDivineEscape:
7437 16 tempitem.cost_amount[0]=32;
7438 16 break;
7439
7440 case iHookshot:
7441 16 tempitem.power=0;
7442 16 tempitem.flags&=~ITEM_FLAG1;
7443 16 tempitem.wpn=wHSHEAD;
7444 16 tempitem.wpn2=wHSCHAIN_H;
7445 16 tempitem.wpn4=wHSHANDLE;
7446 16 tempitem.wpn3=wHSCHAIN_V;
7447 16 tempitem.misc1=50;
7448 16 tempitem.misc2=100;
7449 16 break;
7450
7451 case iLongshot:
7452 16 tempitem.power=0;
7453 16 tempitem.flags&=~ITEM_FLAG1;
7454 16 tempitem.wpn=wLSHEAD;
7455 16 tempitem.wpn2=wLSCHAIN_H;
7456 16 tempitem.wpn4=wLSHANDLE;
7457 16 tempitem.wpn3=wLSCHAIN_V;
7458 16 tempitem.misc1=99;
7459 16 tempitem.misc2=100;
7460 16 break;
7461
7462 case iHammer:
7463 16 tempitem.power=4;
7464 16 tempitem.wpn=wHAMMER;
7465 16 tempitem.wpn2=iwHammerSmack;
7466 16 break;
7467
7468 case iCByrna:
7469 16 tempitem.power=1;
7470 16 tempitem.wpn=wCBYRNA;
7471 16 tempitem.wpn2=wCBYRNASLASH;
7472 16 tempitem.wpn3=wCBYRNAORB;
7473 16 tempitem.misc1=4;
7474 16 tempitem.misc2=16;
7475 16 tempitem.misc3=1;
7476 16 tempitem.cost_amount[0]=1;
7477 16 break;
7478
7479 case iWhistle:
7480 16 tempitem.wpn=wWIND;
7481 16 tempitem.misc1=3;
7482 16 tempitem.flags|=ITEM_FLAG1;
7483 16 break;
7484
7485 case iBRing:
7486 16 tempitem.power=2;
7487 16 tempitem.misc1=spBLUE;
7488 16 break;
7489
7490 case iRRing:
7491 16 tempitem.power=4;
7492 16 tempitem.misc1=spRED;
7493 16 break;
7494
7495 case iGRing:
7496 16 tempitem.power=8;
7497 16 tempitem.misc1=spGOLD;
7498 16 break;
7499
7500 case iSpinScroll:
7501 16 tempitem.power = 2;
7502 16 tempitem.misc1 = 1;
7503 16 break;
7504
7505 case iL2SpinScroll:
7506 16 tempitem.family=itype_spinscroll2;
7507 16 tempitem.fam_type=1;
7508 16 tempitem.cost_amount[0]=8;
7509 16 tempitem.power=2;
7510 16 tempitem.misc1 = 20;
7511 16 break;
7512
7513 case iQuakeScroll:
7514 16 tempitem.misc1=0x10;
7515 16 tempitem.misc2=64;
7516 16 break;
7517
7518 case iL2QuakeScroll:
7519 16 tempitem.family=itype_quakescroll2;
7520 16 tempitem.fam_type=1;
7521 16 tempitem.power = 2;
7522 16 tempitem.misc1=0x20;
7523 16 tempitem.misc2=192;
7524 16 tempitem.cost_amount[0]=8;
7525 16 break;
7526
7527 case iChargeRing:
7528 16 tempitem.misc1=64;
7529 16 tempitem.misc2=128;
7530 16 break;
7531
7532 case iL2ChargeRing:
7533 16 tempitem.misc1=32;
7534 16 tempitem.misc2=64;
7535 16 break;
7536
7537 case iOldGlove:
7538 16 tempitem.flags |= ITEM_FLAG1;
7539
7540 //fallthrough
7541 case iBombBagL4:
7542 case iWalletL3:
7543 case iQuiverL4:
7544 case iBracelet:
7545 80 tempitem.power = 1;
7546 80 break;
7547
7548 case iL2Bracelet:
7549 16 tempitem.power = 2;
7550 16 break;
7551
7552 case iMKey:
7553 16 tempitem.power=0xFF;
7554 16 tempitem.flags |= ITEM_FLAG1;
7555 16 break;
7556 }
7557 4096 }
7558
7559
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 7)
7560 {
7561
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7562 {
7563 case iStoneAgony:
7564 case iStompBoots:
7565 case iPerilRing:
7566 case iWhimsicalRing:
7567 {
7568 64 reset_itembuf(&tempitem, i);
7569 64 strcpy(item_string[i],old_item_string[i]);
7570 64 break;
7571 }
7572 }
7573 4096 }
7574
7575
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 8) // May 2007: Some corrections.
7576 {
7577
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7578 {
7579 case iMShield:
7580 16 tempitem.misc1|=shFLAME;
7581 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7582
7583
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7584 {
7585 tempitem.misc2 |= shSWORD;
7586 }
7587
7588 // fallthrough
7589 case iShield:
7590 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7591
7592 // fallthrough
7593 case iSShield:
7594 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7595
7596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7597 {
7598 tempitem.misc2 |= shROCK;
7599 }
7600
7601 48 break;
7602
7603 case iWhispRing:
7604 16 tempitem.power=1;
7605 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7606 16 tempitem.misc1 = 3;
7607 16 break;
7608
7609 case iL2WhispRing:
7610 16 tempitem.power=0;
7611 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7612 16 tempitem.misc1 = 3;
7613 16 break;
7614
7615 case iL2Ladder:
7616 case iBow:
7617 case iCByrna:
7618 48 tempitem.power = 1;
7619 48 break;
7620 }
7621 4096 }
7622
7623
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29184 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33280 if(s_version < 9 && i==iClock)
7624 {
7625 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7626 16 }
7627
7628 //add the misc flag for bomb
7629
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29184 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33280 if(s_version < 10 && tempitem.family == itype_bomb)
7630 {
7631 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7632 16 }
7633
7634
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29184 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
33280 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7635 {
7636 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7637 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7638 32 }
7639
7640
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 12) // June 2007: More Misc. attributes.
7641 {
7642
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7643 {
7644 case iFBrang:
7645 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7646
7647 //fallthrough
7648 case iMBrang:
7649 32 tempitem.misc3 |= shSWORD|shMAGIC;
7650
7651 //fallthrough
7652 case iHookshot:
7653 case iLongshot:
7654 //fallthrough
7655 64 tempitem.misc3 |= shFIREBALL;
7656
7657 case iBrang:
7658 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7659 80 break;
7660 }
7661
7662
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 32 times.
✓ Branch 7 taken 1956 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 48 times.
✓ Branch 12 taken 48 times.
✓ Branch 13 taken 1740 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
4096 switch(tempitem.family)
7663 {
7664 case itype_hoverboots:
7665 16 tempitem.usesound = WAV_ZN1HOVER;
7666 16 break;
7667
7668 case itype_wand:
7669 16 tempitem.usesound = WAV_WAND;
7670 16 break;
7671
7672 case itype_book:
7673 16 tempitem.usesound = WAV_FIRE;
7674 16 break;
7675
7676 case itype_arrow:
7677 48 tempitem.usesound = WAV_ARROW;
7678 48 break;
7679
7680 case itype_hookshot:
7681 32 tempitem.usesound = WAV_HOOKSHOT;
7682 32 break;
7683
7684 case itype_brang:
7685 48 tempitem.usesound = WAV_BRANG;
7686 48 break;
7687
7688 case itype_shield:
7689 48 tempitem.usesound = WAV_CHINK;
7690 48 break;
7691
7692 case itype_sword:
7693 1740 tempitem.usesound = WAV_SWORD;
7694 1740 break;
7695
7696 case itype_whistle:
7697 16 tempitem.usesound = WAV_WHISTLE;
7698 16 break;
7699
7700 case itype_hammer:
7701 16 tempitem.usesound = WAV_HAMMER;
7702 16 break;
7703
7704 case itype_divinefire:
7705 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7706 16 break;
7707
7708 case itype_divineescape:
7709 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7710 16 break;
7711
7712 case itype_divineprotection:
7713 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7714 16 break;
7715
7716 case itype_bomb:
7717 case itype_sbomb:
7718 case itype_quakescroll:
7719 case itype_quakescroll2:
7720 64 tempitem.usesound = WAV_BOMB;
7721 64 break;
7722
7723 case itype_spinscroll:
7724 case itype_spinscroll2:
7725 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7726 32 break;
7727 }
7728 4096 }
7729
7730
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 13) // July 2007
7731 {
7732
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7733 {
7734 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7735 16 tempitem.power = 1;
7736 16 tempitem.flags|=ITEM_FLAG1;
7737 16 }
7738
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7739 16 tempitem.flags|=ITEM_FLAG1;
7740
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7741 {
7742 16 tempitem.flags|=ITEM_FLAG1;
7743 16 tempitem.power = 2;
7744 16 }
7745 4096 }
7746
7747
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 14) // August 2007
7748 {
7749
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7750 {
7751 32 tempitem.usesound = WAV_SCALE;
7752
7753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7754 32 tempitem.misc3=50;
7755 32 }
7756
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7757 {
7758 32 tempitem.flags |= ITEM_GAINOLD;
7759 32 }
7760 4096 }
7761
7762
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 17) // November 2007
7763 {
7764
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7765 {
7766 tempitem.wpn3 = wFIRE;
7767 }
7768
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7769 {
7770 16 tempitem.flags|=ITEM_FLAG1;
7771 16 }
7772 4096 }
7773
7774
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 18) // New Year's Eve 2007
7775 {
7776
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7777 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7778
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7779 16 tempitem.misc1 = 768; // Frames until it goes
7780
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7781 {
7782
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7783 {
7784 16 tempitem.misc2 = 1; // Cutscene 1
7785 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7786 16 }
7787 32 }
7788 4096 }
7789
7790
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 19) // January 2008
7791 {
7792
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7793 {
7794 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7795 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7796 16 }
7797 4096 }
7798
7799
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 20) // October 2008
7800 {
7801
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7802 {
7803 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7804 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7805 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7806 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7807 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7808 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7809 16 }
7810 4096 }
7811
7812
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 21) // November 2008
7813 {
7814
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7815 {
7816 tempitem.flags &= ~0x0100;
7817
7818 if(tempitem.family == itype_sword ||
7819 tempitem.family == itype_wand ||
7820 tempitem.family == itype_candle ||
7821 tempitem.family == itype_cbyrna)
7822 {
7823 tempitem.flags |= ITEM_FLAG4;
7824 }
7825 }
7826 4096 }
7827
7828
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 22) // September 2009
7829 {
7830
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7831 {
7832 32 tempitem.misc3 = tempitem.power/2;
7833 32 }
7834 4096 }
7835
7836
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 23) // March 2011
7837 {
7838
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7839 16 tempitem.wpn5 = wFIRE;
7840
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7841 16 tempitem.wpn2 = wFIRE;
7842 4096 }
7843
7844 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7845 // whether it was or not, and a lot of existing quests depended on the
7846 // incorrect behavior.
7847
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 4096 times.
33280 if(s_version < 25) // January 2012
7848 {
7849
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7850 64 tempitem.flags |= 16;
7851
7852
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7853 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7854 4096 }
7855
7856
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7857 {
7858
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7859 {
7860 case itype_sword:
7861 {
7862 7811 tempitem.flags &= ~(ITEM_FLAG5);
7863 7811 tempitem.misc3 = 0;
7864 7811 tempitem.misc4 = 0;
7865 7811 tempitem.misc5 = 0;
7866 7811 tempitem.misc6 = 0;
7867 7811 tempitem.misc7 = 0;
7868 7811 tempitem.misc8 = 0;
7869 7811 tempitem.misc9 = 0;
7870 7811 tempitem.misc10 = 0;
7871 7811 tempitem.wpn4 = 0;
7872 7811 tempitem.wpn5 = 0;
7873 7811 tempitem.wpn6 = 0;
7874 7811 tempitem.wpn7 = 0;
7875 7811 tempitem.wpn8 = 0;
7876 7811 tempitem.wpn9 = 0;
7877 7811 tempitem.wpn10 = 0;
7878 7811 break;
7879 }
7880 case itype_brang:
7881 {
7882 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7883 277 tempitem.misc2 = 0;
7884 277 tempitem.misc5 = 0;
7885 277 tempitem.misc6 = 0;
7886 277 tempitem.misc7 = 0;
7887 277 tempitem.misc8 = 0;
7888 277 tempitem.misc9 = 0;
7889 277 tempitem.misc10 = 0;
7890 277 tempitem.wpn4 = 0;
7891 277 tempitem.wpn5 = 0;
7892 277 tempitem.wpn6 = 0;
7893 277 tempitem.wpn7 = 0;
7894 277 tempitem.wpn8 = 0;
7895 277 tempitem.wpn9 = 0;
7896 277 tempitem.wpn10 = 0;
7897 277 break;
7898 }
7899 case itype_arrow:
7900 {
7901 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7902 274 tempitem.misc2 = 0;
7903 274 tempitem.misc3 = 0;
7904 274 tempitem.misc4 = 0;
7905 274 tempitem.misc5 = 0;
7906 274 tempitem.misc6 = 0;
7907 274 tempitem.misc7 = 0;
7908 274 tempitem.misc8 = 0;
7909 274 tempitem.misc9 = 0;
7910 274 tempitem.misc10 = 0;
7911 274 tempitem.wpn4 = 0;
7912 274 tempitem.wpn5 = 0;
7913 274 tempitem.wpn6 = 0;
7914 274 tempitem.wpn7 = 0;
7915 274 tempitem.wpn8 = 0;
7916 274 tempitem.wpn9 = 0;
7917 274 tempitem.wpn10 = 0;
7918 274 break;
7919 }
7920 case itype_candle:
7921 {
7922 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7923 222 tempitem.misc1 = 0;
7924 222 tempitem.misc2 = 0;
7925 222 tempitem.misc3 = 0;
7926 222 tempitem.misc4 = 0;
7927 222 tempitem.misc5 = 0;
7928 222 tempitem.misc6 = 0;
7929 222 tempitem.misc7 = 0;
7930 222 tempitem.misc8 = 0;
7931 222 tempitem.misc9 = 0;
7932 222 tempitem.misc10 = 0;
7933 222 tempitem.wpn4 = 0;
7934 222 tempitem.wpn5 = 0;
7935 222 tempitem.wpn6 = 0;
7936 222 tempitem.wpn7 = 0;
7937 222 tempitem.wpn8 = 0;
7938 222 tempitem.wpn9 = 0;
7939 222 tempitem.wpn10 = 0;
7940 222 break;
7941 }
7942 case itype_whistle:
7943 {
7944 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7945 138 tempitem.misc3 = 0;
7946 138 tempitem.misc4 = 0;
7947 138 tempitem.misc5 = 0;
7948 138 tempitem.misc6 = 0;
7949 138 tempitem.misc7 = 0;
7950 138 tempitem.misc8 = 0;
7951 138 tempitem.misc9 = 0;
7952 138 tempitem.misc10 = 0;
7953 138 tempitem.wpn2 = 0;
7954 138 tempitem.wpn3 = 0;
7955 138 tempitem.wpn4 = 0;
7956 138 tempitem.wpn5 = 0;
7957 138 tempitem.wpn6 = 0;
7958 138 tempitem.wpn7 = 0;
7959 138 tempitem.wpn8 = 0;
7960 138 tempitem.wpn9 = 0;
7961 138 tempitem.wpn10 = 0;
7962 138 break;
7963 }
7964 case itype_bait:
7965 {
7966 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7967 93 tempitem.misc2 = 0;
7968 93 tempitem.misc3 = 0;
7969 93 tempitem.misc4 = 0;
7970 93 tempitem.misc5 = 0;
7971 93 tempitem.misc6 = 0;
7972 93 tempitem.misc7 = 0;
7973 93 tempitem.misc8 = 0;
7974 93 tempitem.misc9 = 0;
7975 93 tempitem.misc10 = 0;
7976 93 tempitem.wpn2 = 0;
7977 93 tempitem.wpn3 = 0;
7978 93 tempitem.wpn4 = 0;
7979 93 tempitem.wpn5 = 0;
7980 93 tempitem.wpn6 = 0;
7981 93 tempitem.wpn7 = 0;
7982 93 tempitem.wpn8 = 0;
7983 93 tempitem.wpn9 = 0;
7984 93 tempitem.wpn10 = 0;
7985 93 break;
7986 }
7987 case itype_letter:
7988 {
7989 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7990 184 tempitem.misc1 = 0;
7991 184 tempitem.misc2 = 0;
7992 184 tempitem.misc3 = 0;
7993 184 tempitem.misc4 = 0;
7994 184 tempitem.misc5 = 0;
7995 184 tempitem.misc6 = 0;
7996 184 tempitem.misc7 = 0;
7997 184 tempitem.misc8 = 0;
7998 184 tempitem.misc9 = 0;
7999 184 tempitem.misc10 = 0;
8000 184 tempitem.wpn = 0;
8001 184 tempitem.wpn2 = 0;
8002 184 tempitem.wpn3 = 0;
8003 184 tempitem.wpn4 = 0;
8004 184 tempitem.wpn5 = 0;
8005 184 tempitem.wpn6 = 0;
8006 184 tempitem.wpn7 = 0;
8007 184 tempitem.wpn8 = 0;
8008 184 tempitem.wpn9 = 0;
8009 184 tempitem.wpn10 = 0;
8010 184 break;
8011 }
8012 case itype_potion:
8013 {
8014 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8015 183 tempitem.misc3 = 0;
8016 183 tempitem.misc4 = 0;
8017 183 tempitem.misc5 = 0;
8018 183 tempitem.misc6 = 0;
8019 183 tempitem.misc7 = 0;
8020 183 tempitem.misc8 = 0;
8021 183 tempitem.misc9 = 0;
8022 183 tempitem.misc10 = 0;
8023 183 tempitem.wpn = 0;
8024 183 tempitem.wpn2 = 0;
8025 183 tempitem.wpn3 = 0;
8026 183 tempitem.wpn4 = 0;
8027 183 tempitem.wpn5 = 0;
8028 183 tempitem.wpn6 = 0;
8029 183 tempitem.wpn7 = 0;
8030 183 tempitem.wpn8 = 0;
8031 183 tempitem.wpn9 = 0;
8032 183 tempitem.wpn10 = 0;
8033 183 break;
8034 }
8035 case itype_wand:
8036 {
8037 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8038 107 tempitem.misc1 = 0;
8039 107 tempitem.misc2 = 0;
8040 107 tempitem.misc3 = 0;
8041 107 tempitem.misc4 = 0;
8042 107 tempitem.misc5 = 0;
8043 107 tempitem.misc6 = 0;
8044 107 tempitem.misc7 = 0;
8045 107 tempitem.misc8 = 0;
8046 107 tempitem.misc9 = 0;
8047 107 tempitem.misc10 = 0;
8048 107 tempitem.wpn4 = 0;
8049 107 tempitem.wpn5 = 0;
8050 107 tempitem.wpn6 = 0;
8051 107 tempitem.wpn7 = 0;
8052 107 tempitem.wpn8 = 0;
8053 107 tempitem.wpn9 = 0;
8054 107 tempitem.wpn10 = 0;
8055 107 break;
8056 }
8057 case itype_ring:
8058 {
8059 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8060 302 tempitem.misc2 = 0;
8061 302 tempitem.misc3 = 0;
8062 302 tempitem.misc4 = 0;
8063 302 tempitem.misc5 = 0;
8064 302 tempitem.misc6 = 0;
8065 302 tempitem.misc7 = 0;
8066 302 tempitem.misc8 = 0;
8067 302 tempitem.misc9 = 0;
8068 302 tempitem.misc10 = 0;
8069 302 tempitem.wpn = 0;
8070 302 tempitem.wpn2 = 0;
8071 302 tempitem.wpn3 = 0;
8072 302 tempitem.wpn4 = 0;
8073 302 tempitem.wpn5 = 0;
8074 302 tempitem.wpn6 = 0;
8075 302 tempitem.wpn7 = 0;
8076 302 tempitem.wpn8 = 0;
8077 302 tempitem.wpn9 = 0;
8078 302 tempitem.wpn10 = 0;
8079 302 break;
8080 }
8081 case itype_wallet:
8082 {
8083 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8084 276 tempitem.misc3 = 0;
8085 276 tempitem.misc4 = 0;
8086 276 tempitem.misc5 = 0;
8087 276 tempitem.misc6 = 0;
8088 276 tempitem.misc7 = 0;
8089 276 tempitem.misc8 = 0;
8090 276 tempitem.misc9 = 0;
8091 276 tempitem.misc10 = 0;
8092 276 tempitem.wpn = 0;
8093 276 tempitem.wpn2 = 0;
8094 276 tempitem.wpn3 = 0;
8095 276 tempitem.wpn4 = 0;
8096 276 tempitem.wpn5 = 0;
8097 276 tempitem.wpn6 = 0;
8098 276 tempitem.wpn7 = 0;
8099 276 tempitem.wpn8 = 0;
8100 276 tempitem.wpn9 = 0;
8101 276 tempitem.wpn10 = 0;
8102 276 break;
8103 }
8104 case itype_amulet:
8105 {
8106 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8107 183 tempitem.misc1 = 0;
8108 183 tempitem.misc2 = 0;
8109 183 tempitem.misc3 = 0;
8110 183 tempitem.misc4 = 0;
8111 183 tempitem.misc5 = 0;
8112 183 tempitem.misc6 = 0;
8113 183 tempitem.misc7 = 0;
8114 183 tempitem.misc8 = 0;
8115 183 tempitem.misc9 = 0;
8116 183 tempitem.misc10 = 0;
8117 183 tempitem.wpn = 0;
8118 183 tempitem.wpn2 = 0;
8119 183 tempitem.wpn3 = 0;
8120 183 tempitem.wpn4 = 0;
8121 183 tempitem.wpn5 = 0;
8122 183 tempitem.wpn6 = 0;
8123 183 tempitem.wpn7 = 0;
8124 183 tempitem.wpn8 = 0;
8125 183 tempitem.wpn9 = 0;
8126 183 tempitem.wpn10 = 0;
8127 183 break;
8128 }
8129 case itype_shield:
8130 {
8131 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8132 283 tempitem.misc3 = 0;
8133 283 tempitem.misc4 = 0;
8134 283 tempitem.misc5 = 0;
8135 283 tempitem.misc6 = 0;
8136 283 tempitem.misc7 = 0;
8137 283 tempitem.misc8 = 0;
8138 283 tempitem.misc9 = 0;
8139 283 tempitem.misc10 = 0;
8140 283 tempitem.wpn = 0;
8141 283 tempitem.wpn2 = 0;
8142 283 tempitem.wpn3 = 0;
8143 283 tempitem.wpn4 = 0;
8144 283 tempitem.wpn5 = 0;
8145 283 tempitem.wpn6 = 0;
8146 283 tempitem.wpn7 = 0;
8147 283 tempitem.wpn8 = 0;
8148 283 tempitem.wpn9 = 0;
8149 283 tempitem.wpn10 = 0;
8150 283 break;
8151 }
8152 case itype_bow:
8153 {
8154 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8155 184 tempitem.misc1 = 0;
8156 184 tempitem.misc2 = 0;
8157 184 tempitem.misc3 = 0;
8158 184 tempitem.misc4 = 0;
8159 184 tempitem.misc5 = 0;
8160 184 tempitem.misc6 = 0;
8161 184 tempitem.misc7 = 0;
8162 184 tempitem.misc8 = 0;
8163 184 tempitem.misc9 = 0;
8164 184 tempitem.misc10 = 0;
8165 184 tempitem.wpn = 0;
8166 184 tempitem.wpn2 = 0;
8167 184 tempitem.wpn3 = 0;
8168 184 tempitem.wpn4 = 0;
8169 184 tempitem.wpn5 = 0;
8170 184 tempitem.wpn6 = 0;
8171 184 tempitem.wpn7 = 0;
8172 184 tempitem.wpn8 = 0;
8173 184 tempitem.wpn9 = 0;
8174 184 tempitem.wpn10 = 0;
8175 184 break;
8176 }
8177 case itype_raft:
8178 {
8179 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8180 92 tempitem.misc1 = 0;
8181 92 tempitem.misc2 = 0;
8182 92 tempitem.misc3 = 0;
8183 92 tempitem.misc4 = 0;
8184 92 tempitem.misc5 = 0;
8185 92 tempitem.misc6 = 0;
8186 92 tempitem.misc7 = 0;
8187 92 tempitem.misc8 = 0;
8188 92 tempitem.misc9 = 0;
8189 92 tempitem.misc10 = 0;
8190 92 tempitem.wpn = 0;
8191 92 tempitem.wpn2 = 0;
8192 92 tempitem.wpn3 = 0;
8193 92 tempitem.wpn4 = 0;
8194 92 tempitem.wpn5 = 0;
8195 92 tempitem.wpn6 = 0;
8196 92 tempitem.wpn7 = 0;
8197 92 tempitem.wpn8 = 0;
8198 92 tempitem.wpn9 = 0;
8199 92 tempitem.wpn10 = 0;
8200 92 break;
8201 }
8202 case itype_ladder:
8203 {
8204 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8205 184 tempitem.misc1 = 0;
8206 184 tempitem.misc2 = 0;
8207 184 tempitem.misc3 = 0;
8208 184 tempitem.misc4 = 0;
8209 184 tempitem.misc5 = 0;
8210 184 tempitem.misc6 = 0;
8211 184 tempitem.misc7 = 0;
8212 184 tempitem.misc8 = 0;
8213 184 tempitem.misc9 = 0;
8214 184 tempitem.misc10 = 0;
8215 184 tempitem.wpn = 0;
8216 184 tempitem.wpn2 = 0;
8217 184 tempitem.wpn3 = 0;
8218 184 tempitem.wpn4 = 0;
8219 184 tempitem.wpn5 = 0;
8220 184 tempitem.wpn6 = 0;
8221 184 tempitem.wpn7 = 0;
8222 184 tempitem.wpn8 = 0;
8223 184 tempitem.wpn9 = 0;
8224 184 tempitem.wpn10 = 0;
8225 184 break;
8226 }
8227 case itype_book:
8228 {
8229 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8230 107 tempitem.misc1 = 0;
8231 107 tempitem.misc2 = 0;
8232 107 tempitem.misc3 = 0;
8233 107 tempitem.misc4 = 0;
8234 107 tempitem.misc5 = 0;
8235 107 tempitem.misc6 = 0;
8236 107 tempitem.misc7 = 0;
8237 107 tempitem.misc8 = 0;
8238 107 tempitem.misc9 = 0;
8239 107 tempitem.misc10 = 0;
8240 107 tempitem.wpn3 = 0;
8241 107 tempitem.wpn4 = 0;
8242 107 tempitem.wpn5 = 0;
8243 107 tempitem.wpn6 = 0;
8244 107 tempitem.wpn7 = 0;
8245 107 tempitem.wpn8 = 0;
8246 107 tempitem.wpn9 = 0;
8247 107 tempitem.wpn10 = 0;
8248 107 break;
8249 }
8250 case itype_magickey:
8251 {
8252 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8253 92 tempitem.misc1 = 0;
8254 92 tempitem.misc2 = 0;
8255 92 tempitem.misc3 = 0;
8256 92 tempitem.misc4 = 0;
8257 92 tempitem.misc5 = 0;
8258 92 tempitem.misc6 = 0;
8259 92 tempitem.misc7 = 0;
8260 92 tempitem.misc8 = 0;
8261 92 tempitem.misc9 = 0;
8262 92 tempitem.misc10 = 0;
8263 92 tempitem.wpn = 0;
8264 92 tempitem.wpn2 = 0;
8265 92 tempitem.wpn3 = 0;
8266 92 tempitem.wpn4 = 0;
8267 92 tempitem.wpn5 = 0;
8268 92 tempitem.wpn6 = 0;
8269 92 tempitem.wpn7 = 0;
8270 92 tempitem.wpn8 = 0;
8271 92 tempitem.wpn9 = 0;
8272 92 tempitem.wpn10 = 0;
8273 92 break;
8274 }
8275 case itype_bracelet:
8276 {
8277 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8278 279 tempitem.misc1 = 0;
8279 279 tempitem.misc2 = 0;
8280 279 tempitem.misc3 = 0;
8281 279 tempitem.misc4 = 0;
8282 279 tempitem.misc5 = 0;
8283 279 tempitem.misc6 = 0;
8284 279 tempitem.misc7 = 0;
8285 279 tempitem.misc8 = 0;
8286 279 tempitem.misc9 = 0;
8287 279 tempitem.misc10 = 0;
8288 279 tempitem.wpn = 0;
8289 279 tempitem.wpn2 = 0;
8290 279 tempitem.wpn3 = 0;
8291 279 tempitem.wpn4 = 0;
8292 279 tempitem.wpn5 = 0;
8293 279 tempitem.wpn6 = 0;
8294 279 tempitem.wpn7 = 0;
8295 279 tempitem.wpn8 = 0;
8296 279 tempitem.wpn9 = 0;
8297 279 tempitem.wpn10 = 0;
8298 279 break;
8299 }
8300 case itype_flippers:
8301 {
8302 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8303 93 tempitem.misc1 = 0;
8304 93 tempitem.misc2 = 0;
8305 93 tempitem.misc3 = 0;
8306 93 tempitem.misc4 = 0;
8307 93 tempitem.misc5 = 0;
8308 93 tempitem.misc6 = 0;
8309 93 tempitem.misc7 = 0;
8310 93 tempitem.misc8 = 0;
8311 93 tempitem.misc9 = 0;
8312 93 tempitem.misc10 = 0;
8313 93 tempitem.wpn = 0;
8314 93 tempitem.wpn2 = 0;
8315 93 tempitem.wpn3 = 0;
8316 93 tempitem.wpn4 = 0;
8317 93 tempitem.wpn5 = 0;
8318 93 tempitem.wpn6 = 0;
8319 93 tempitem.wpn7 = 0;
8320 93 tempitem.wpn8 = 0;
8321 93 tempitem.wpn9 = 0;
8322 93 tempitem.wpn10 = 0;
8323 93 break;
8324 }
8325 case itype_boots:
8326 {
8327 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8328 94 tempitem.misc1 = 0;
8329 94 tempitem.misc2 = 0;
8330 94 tempitem.misc3 = 0;
8331 94 tempitem.misc4 = 0;
8332 94 tempitem.misc5 = 0;
8333 94 tempitem.misc6 = 0;
8334 94 tempitem.misc7 = 0;
8335 94 tempitem.misc8 = 0;
8336 94 tempitem.misc9 = 0;
8337 94 tempitem.misc10 = 0;
8338 94 tempitem.wpn = 0;
8339 94 tempitem.wpn2 = 0;
8340 94 tempitem.wpn3 = 0;
8341 94 tempitem.wpn4 = 0;
8342 94 tempitem.wpn5 = 0;
8343 94 tempitem.wpn6 = 0;
8344 94 tempitem.wpn7 = 0;
8345 94 tempitem.wpn8 = 0;
8346 94 tempitem.wpn9 = 0;
8347 94 tempitem.wpn10 = 0;
8348 94 break;
8349 }
8350 case itype_hookshot:
8351 {
8352 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8353 184 tempitem.misc5 = 0;
8354 184 tempitem.misc6 = 0;
8355 184 tempitem.misc7 = 0;
8356 184 tempitem.misc8 = 0;
8357 184 tempitem.misc9 = 0;
8358 184 tempitem.misc10 = 0;
8359 184 tempitem.wpn5 = 0;
8360 184 tempitem.wpn6 = 0;
8361 184 tempitem.wpn7 = 0;
8362 184 tempitem.wpn8 = 0;
8363 184 tempitem.wpn9 = 0;
8364 184 tempitem.wpn10 = 0;
8365 184 break;
8366 }
8367 case itype_lens:
8368 {
8369 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8370 92 tempitem.misc2 = 0;
8371 92 tempitem.misc3 = 0;
8372 92 tempitem.misc4 = 0;
8373 92 tempitem.misc5 = 0;
8374 92 tempitem.misc6 = 0;
8375 92 tempitem.misc7 = 0;
8376 92 tempitem.misc8 = 0;
8377 92 tempitem.misc9 = 0;
8378 92 tempitem.misc10 = 0;
8379 92 tempitem.wpn = 0;
8380 92 tempitem.wpn2 = 0;
8381 92 tempitem.wpn3 = 0;
8382 92 tempitem.wpn4 = 0;
8383 92 tempitem.wpn5 = 0;
8384 92 tempitem.wpn6 = 0;
8385 92 tempitem.wpn7 = 0;
8386 92 tempitem.wpn8 = 0;
8387 92 tempitem.wpn9 = 0;
8388 92 tempitem.wpn10 = 0;
8389 92 break;
8390 }
8391 case itype_hammer:
8392 {
8393 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8394 93 tempitem.misc1 = 0;
8395 93 tempitem.misc2 = 0;
8396 93 tempitem.misc3 = 0;
8397 93 tempitem.misc4 = 0;
8398 93 tempitem.misc5 = 0;
8399 93 tempitem.misc6 = 0;
8400 93 tempitem.misc7 = 0;
8401 93 tempitem.misc8 = 0;
8402 93 tempitem.misc9 = 0;
8403 93 tempitem.misc10 = 0;
8404 93 tempitem.wpn3 = 0;
8405 93 tempitem.wpn4 = 0;
8406 93 tempitem.wpn5 = 0;
8407 93 tempitem.wpn6 = 0;
8408 93 tempitem.wpn7 = 0;
8409 93 tempitem.wpn8 = 0;
8410 93 tempitem.wpn9 = 0;
8411 93 tempitem.wpn10 = 0;
8412 93 break;
8413 }
8414 case itype_divinefire:
8415 {
8416 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8417 92 tempitem.misc3 = 0;
8418 92 tempitem.misc4 = 0;
8419 92 tempitem.misc5 = 0;
8420 92 tempitem.misc6 = 0;
8421 92 tempitem.misc7 = 0;
8422 92 tempitem.misc8 = 0;
8423 92 tempitem.misc9 = 0;
8424 92 tempitem.misc10 = 0;
8425 92 tempitem.wpn6 = 0;
8426 92 tempitem.wpn7 = 0;
8427 92 tempitem.wpn8 = 0;
8428 92 tempitem.wpn9 = 0;
8429 92 tempitem.wpn10 = 0;
8430 92 break;
8431 }
8432 case itype_divineescape:
8433 {
8434 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8435 92 tempitem.misc2 = 0;
8436 92 tempitem.misc3 = 0;
8437 92 tempitem.misc4 = 0;
8438 92 tempitem.misc5 = 0;
8439 92 tempitem.misc6 = 0;
8440 92 tempitem.misc7 = 0;
8441 92 tempitem.misc8 = 0;
8442 92 tempitem.misc9 = 0;
8443 92 tempitem.misc10 = 0;
8444 92 tempitem.wpn = 0;
8445 92 tempitem.wpn2 = 0;
8446 92 tempitem.wpn3 = 0;
8447 92 tempitem.wpn4 = 0;
8448 92 tempitem.wpn5 = 0;
8449 92 tempitem.wpn6 = 0;
8450 92 tempitem.wpn7 = 0;
8451 92 tempitem.wpn8 = 0;
8452 92 tempitem.wpn9 = 0;
8453 92 tempitem.wpn10 = 0;
8454 92 break;
8455 }
8456 case itype_divineprotection:
8457 {
8458 92 tempitem.flags &= ~ (ITEM_FLAG5);
8459 92 tempitem.misc2 = 0;
8460 92 tempitem.misc3 = 0;
8461 92 tempitem.misc4 = 0;
8462 92 tempitem.misc5 = 0;
8463 92 tempitem.misc6 = 0;
8464 92 tempitem.misc7 = 0;
8465 92 tempitem.misc8 = 0;
8466 92 tempitem.misc9 = 0;
8467 92 tempitem.misc10 = 0;
8468 92 break;
8469 }
8470 case itype_bomb:
8471 {
8472 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8473 107 tempitem.misc4 = 0;
8474 107 tempitem.misc5 = 0;
8475 107 tempitem.misc6 = 0;
8476 107 tempitem.misc7 = 0;
8477 107 tempitem.misc8 = 0;
8478 107 tempitem.misc9 = 0;
8479 107 tempitem.misc10 = 0;
8480 107 tempitem.wpn3 = 0;
8481 107 tempitem.wpn4 = 0;
8482 107 tempitem.wpn5 = 0;
8483 107 tempitem.wpn6 = 0;
8484 107 tempitem.wpn7 = 0;
8485 107 tempitem.wpn8 = 0;
8486 107 tempitem.wpn9 = 0;
8487 107 tempitem.wpn10 = 0;
8488 107 break;
8489 }
8490 case itype_sbomb:
8491 {
8492 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8493 92 tempitem.misc4 = 0;
8494 92 tempitem.misc5 = 0;
8495 92 tempitem.misc6 = 0;
8496 92 tempitem.misc7 = 0;
8497 92 tempitem.misc8 = 0;
8498 92 tempitem.misc9 = 0;
8499 92 tempitem.misc10 = 0;
8500 92 tempitem.wpn3 = 0;
8501 92 tempitem.wpn4 = 0;
8502 92 tempitem.wpn5 = 0;
8503 92 tempitem.wpn6 = 0;
8504 92 tempitem.wpn7 = 0;
8505 92 tempitem.wpn8 = 0;
8506 92 tempitem.wpn9 = 0;
8507 92 tempitem.wpn10 = 0;
8508 92 break;
8509 }
8510 case itype_clock:
8511 {
8512 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8513 93 tempitem.misc2 = 0;
8514 93 tempitem.misc3 = 0;
8515 93 tempitem.misc4 = 0;
8516 93 tempitem.misc5 = 0;
8517 93 tempitem.misc6 = 0;
8518 93 tempitem.misc7 = 0;
8519 93 tempitem.misc8 = 0;
8520 93 tempitem.misc9 = 0;
8521 93 tempitem.misc10 = 0;
8522 93 tempitem.wpn = 0;
8523 93 tempitem.wpn2 = 0;
8524 93 tempitem.wpn3 = 0;
8525 93 tempitem.wpn4 = 0;
8526 93 tempitem.wpn5 = 0;
8527 93 tempitem.wpn6 = 0;
8528 93 tempitem.wpn7 = 0;
8529 93 tempitem.wpn8 = 0;
8530 93 tempitem.wpn9 = 0;
8531 93 tempitem.wpn10 = 0;
8532 93 break;
8533 }
8534 case itype_key:
8535 {
8536 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8537 92 tempitem.misc1 = 0;
8538 92 tempitem.misc2 = 0;
8539 92 tempitem.misc3 = 0;
8540 92 tempitem.misc4 = 0;
8541 92 tempitem.misc5 = 0;
8542 92 tempitem.misc6 = 0;
8543 92 tempitem.misc7 = 0;
8544 92 tempitem.misc8 = 0;
8545 92 tempitem.misc9 = 0;
8546 92 tempitem.misc10 = 0;
8547 92 tempitem.wpn = 0;
8548 92 tempitem.wpn2 = 0;
8549 92 tempitem.wpn3 = 0;
8550 92 tempitem.wpn4 = 0;
8551 92 tempitem.wpn5 = 0;
8552 92 tempitem.wpn6 = 0;
8553 92 tempitem.wpn7 = 0;
8554 92 tempitem.wpn8 = 0;
8555 92 tempitem.wpn9 = 0;
8556 92 tempitem.wpn10 = 0;
8557 92 break;
8558 }
8559 case itype_magiccontainer:
8560 {
8561 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8562 93 tempitem.misc1 = 0;
8563 93 tempitem.misc2 = 0;
8564 93 tempitem.misc3 = 0;
8565 93 tempitem.misc4 = 0;
8566 93 tempitem.misc5 = 0;
8567 93 tempitem.misc6 = 0;
8568 93 tempitem.misc7 = 0;
8569 93 tempitem.misc8 = 0;
8570 93 tempitem.misc9 = 0;
8571 93 tempitem.misc10 = 0;
8572 93 tempitem.wpn = 0;
8573 93 tempitem.wpn2 = 0;
8574 93 tempitem.wpn3 = 0;
8575 93 tempitem.wpn4 = 0;
8576 93 tempitem.wpn5 = 0;
8577 93 tempitem.wpn6 = 0;
8578 93 tempitem.wpn7 = 0;
8579 93 tempitem.wpn8 = 0;
8580 93 tempitem.wpn9 = 0;
8581 93 tempitem.wpn10 = 0;
8582 93 break;
8583 }
8584 case itype_triforcepiece:
8585 {
8586 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8587 184 tempitem.misc3 = 0;
8588 184 tempitem.misc4 = 0;
8589 184 tempitem.misc5 = 0;
8590 184 tempitem.misc6 = 0;
8591 184 tempitem.misc7 = 0;
8592 184 tempitem.misc8 = 0;
8593 184 tempitem.misc9 = 0;
8594 184 tempitem.misc10 = 0;
8595 184 tempitem.wpn = 0;
8596 184 tempitem.wpn2 = 0;
8597 184 tempitem.wpn3 = 0;
8598 184 tempitem.wpn4 = 0;
8599 184 tempitem.wpn5 = 0;
8600 184 tempitem.wpn6 = 0;
8601 184 tempitem.wpn7 = 0;
8602 184 tempitem.wpn8 = 0;
8603 184 tempitem.wpn9 = 0;
8604 184 tempitem.wpn10 = 0;
8605 184 break;
8606 }
8607 case itype_map: case itype_compass: case itype_bosskey:
8608 {
8609 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8610 277 tempitem.misc1 = 0;
8611 277 tempitem.misc2 = 0;
8612 277 tempitem.misc3 = 0;
8613 277 tempitem.misc4 = 0;
8614 277 tempitem.misc5 = 0;
8615 277 tempitem.misc6 = 0;
8616 277 tempitem.misc7 = 0;
8617 277 tempitem.misc8 = 0;
8618 277 tempitem.misc9 = 0;
8619 277 tempitem.misc10 = 0;
8620 277 tempitem.wpn = 0;
8621 277 tempitem.wpn2 = 0;
8622 277 tempitem.wpn3 = 0;
8623 277 tempitem.wpn4 = 0;
8624 277 tempitem.wpn5 = 0;
8625 277 tempitem.wpn6 = 0;
8626 277 tempitem.wpn7 = 0;
8627 277 tempitem.wpn8 = 0;
8628 277 tempitem.wpn9 = 0;
8629 277 tempitem.wpn10 = 0;
8630 277 break;
8631 }
8632 case itype_quiver:
8633 {
8634 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8635 368 tempitem.misc3 = 0;
8636 368 tempitem.misc4 = 0;
8637 368 tempitem.misc5 = 0;
8638 368 tempitem.misc6 = 0;
8639 368 tempitem.misc7 = 0;
8640 368 tempitem.misc8 = 0;
8641 368 tempitem.misc9 = 0;
8642 368 tempitem.misc10 = 0;
8643 368 tempitem.wpn = 0;
8644 368 tempitem.wpn2 = 0;
8645 368 tempitem.wpn3 = 0;
8646 368 tempitem.wpn4 = 0;
8647 368 tempitem.wpn5 = 0;
8648 368 tempitem.wpn6 = 0;
8649 368 tempitem.wpn7 = 0;
8650 368 tempitem.wpn8 = 0;
8651 368 tempitem.wpn9 = 0;
8652 368 tempitem.wpn10 = 0;
8653 368 break;
8654 }
8655 case itype_lkey:
8656 {
8657 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8658 94 tempitem.misc1 = 0;
8659 94 tempitem.misc2 = 0;
8660 94 tempitem.misc3 = 0;
8661 94 tempitem.misc4 = 0;
8662 94 tempitem.misc5 = 0;
8663 94 tempitem.misc6 = 0;
8664 94 tempitem.misc7 = 0;
8665 94 tempitem.misc8 = 0;
8666 94 tempitem.misc9 = 0;
8667 94 tempitem.misc10 = 0;
8668 94 tempitem.wpn = 0;
8669 94 tempitem.wpn2 = 0;
8670 94 tempitem.wpn3 = 0;
8671 94 tempitem.wpn4 = 0;
8672 94 tempitem.wpn5 = 0;
8673 94 tempitem.wpn6 = 0;
8674 94 tempitem.wpn7 = 0;
8675 94 tempitem.wpn8 = 0;
8676 94 tempitem.wpn9 = 0;
8677 94 tempitem.wpn10 = 0;
8678 94 break;
8679 }
8680 case itype_cbyrna:
8681 {
8682 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8683 92 tempitem.misc4 = 0;
8684 92 tempitem.misc5 = 0;
8685 92 tempitem.misc6 = 0;
8686 92 tempitem.misc7 = 0;
8687 92 tempitem.misc8 = 0;
8688 92 tempitem.misc9 = 0;
8689 92 tempitem.misc10 = 0;
8690 92 tempitem.wpn6 = 0;
8691 92 tempitem.wpn7 = 0;
8692 92 tempitem.wpn8 = 0;
8693 92 tempitem.wpn9 = 0;
8694 92 tempitem.wpn10 = 0;
8695 92 break;
8696 }
8697 case itype_rupee: case itype_arrowammo:
8698 {
8699 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8700 1135 tempitem.misc1 = 0;
8701 1135 tempitem.misc2 = 0;
8702 1135 tempitem.misc3 = 0;
8703 1135 tempitem.misc4 = 0;
8704 1135 tempitem.misc5 = 0;
8705 1135 tempitem.misc6 = 0;
8706 1135 tempitem.misc7 = 0;
8707 1135 tempitem.misc8 = 0;
8708 1135 tempitem.misc9 = 0;
8709 1135 tempitem.misc10 = 0;
8710 1135 tempitem.wpn = 0;
8711 1135 tempitem.wpn2 = 0;
8712 1135 tempitem.wpn3 = 0;
8713 1135 tempitem.wpn4 = 0;
8714 1135 tempitem.wpn5 = 0;
8715 1135 tempitem.wpn6 = 0;
8716 1135 tempitem.wpn7 = 0;
8717 1135 tempitem.wpn8 = 0;
8718 1135 tempitem.wpn9 = 0;
8719 1135 tempitem.wpn10 = 0;
8720 1135 break;
8721 }
8722 case itype_fairy:
8723 {
8724 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8725 168 tempitem.misc4 = 0;
8726 168 tempitem.misc5 = 0;
8727 168 tempitem.misc6 = 0;
8728 168 tempitem.misc7 = 0;
8729 168 tempitem.misc8 = 0;
8730 168 tempitem.misc9 = 0;
8731 168 tempitem.misc10 = 0;
8732 168 tempitem.wpn = 0;
8733 168 tempitem.wpn2 = 0;
8734 168 tempitem.wpn3 = 0;
8735 168 tempitem.wpn4 = 0;
8736 168 tempitem.wpn5 = 0;
8737 168 tempitem.wpn6 = 0;
8738 168 tempitem.wpn7 = 0;
8739 168 tempitem.wpn8 = 0;
8740 168 tempitem.wpn9 = 0;
8741 168 tempitem.wpn10 = 0;
8742 168 break;
8743 }
8744 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8745 {
8746 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8747 983 tempitem.misc1 = 0;
8748 983 tempitem.misc2 = 0;
8749 983 tempitem.misc3 = 0;
8750 983 tempitem.misc4 = 0;
8751 983 tempitem.misc5 = 0;
8752 983 tempitem.misc6 = 0;
8753 983 tempitem.misc7 = 0;
8754 983 tempitem.misc8 = 0;
8755 983 tempitem.misc9 = 0;
8756 983 tempitem.misc10 = 0;
8757 983 tempitem.wpn = 0;
8758 983 tempitem.wpn2 = 0;
8759 983 tempitem.wpn3 = 0;
8760 983 tempitem.wpn4 = 0;
8761 983 tempitem.wpn5 = 0;
8762 983 tempitem.wpn6 = 0;
8763 983 tempitem.wpn7 = 0;
8764 983 tempitem.wpn8 = 0;
8765 983 tempitem.wpn9 = 0;
8766 983 tempitem.wpn10 = 0;
8767 983 break;
8768 }
8769 case itype_bombbag:
8770 {
8771 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8772 368 tempitem.misc3 = 0;
8773 368 tempitem.misc4 = 0;
8774 368 tempitem.misc5 = 0;
8775 368 tempitem.misc6 = 0;
8776 368 tempitem.misc7 = 0;
8777 368 tempitem.misc8 = 0;
8778 368 tempitem.misc9 = 0;
8779 368 tempitem.misc10 = 0;
8780 368 tempitem.wpn = 0;
8781 368 tempitem.wpn2 = 0;
8782 368 tempitem.wpn3 = 0;
8783 368 tempitem.wpn4 = 0;
8784 368 tempitem.wpn5 = 0;
8785 368 tempitem.wpn6 = 0;
8786 368 tempitem.wpn7 = 0;
8787 368 tempitem.wpn8 = 0;
8788 368 tempitem.wpn9 = 0;
8789 368 tempitem.wpn10 = 0;
8790 368 break;
8791 }
8792 case itype_rocs:
8793 {
8794 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8795 92 tempitem.misc1 = 0;
8796 92 tempitem.misc2 = 0;
8797 92 tempitem.misc3 = 0;
8798 92 tempitem.misc4 = 0;
8799 92 tempitem.misc5 = 0;
8800 92 tempitem.misc6 = 0;
8801 92 tempitem.misc7 = 0;
8802 92 tempitem.misc8 = 0;
8803 92 tempitem.misc9 = 0;
8804 92 tempitem.misc10 = 0;
8805 92 tempitem.wpn = 0;
8806 92 tempitem.wpn2 = 0;
8807 92 tempitem.wpn3 = 0;
8808 92 tempitem.wpn4 = 0;
8809 92 tempitem.wpn5 = 0;
8810 92 tempitem.wpn6 = 0;
8811 92 tempitem.wpn7 = 0;
8812 92 tempitem.wpn8 = 0;
8813 92 tempitem.wpn9 = 0;
8814 92 tempitem.wpn10 = 0;
8815 92 break;
8816 }
8817 case itype_hoverboots:
8818 {
8819 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8820 92 tempitem.misc2 = 0;
8821 92 tempitem.misc3 = 0;
8822 92 tempitem.misc4 = 0;
8823 92 tempitem.misc5 = 0;
8824 92 tempitem.misc6 = 0;
8825 92 tempitem.misc7 = 0;
8826 92 tempitem.misc8 = 0;
8827 92 tempitem.misc9 = 0;
8828 92 tempitem.misc10 = 0;
8829 92 tempitem.wpn2 = 0;
8830 92 tempitem.wpn3 = 0;
8831 92 tempitem.wpn4 = 0;
8832 92 tempitem.wpn5 = 0;
8833 92 tempitem.wpn6 = 0;
8834 92 tempitem.wpn7 = 0;
8835 92 tempitem.wpn8 = 0;
8836 92 tempitem.wpn9 = 0;
8837 92 tempitem.wpn10 = 0;
8838 92 break;
8839 }
8840 case itype_spinscroll:
8841 {
8842 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8843 92 tempitem.misc2 = 0;
8844 92 tempitem.misc3 = 0;
8845 92 tempitem.misc4 = 0;
8846 92 tempitem.misc5 = 0;
8847 92 tempitem.misc6 = 0;
8848 92 tempitem.misc7 = 0;
8849 92 tempitem.misc8 = 0;
8850 92 tempitem.misc9 = 0;
8851 92 tempitem.misc10 = 0;
8852 92 tempitem.wpn = 0;
8853 92 tempitem.wpn2 = 0;
8854 92 tempitem.wpn3 = 0;
8855 92 tempitem.wpn4 = 0;
8856 92 tempitem.wpn5 = 0;
8857 92 tempitem.wpn6 = 0;
8858 92 tempitem.wpn7 = 0;
8859 92 tempitem.wpn8 = 0;
8860 92 tempitem.wpn9 = 0;
8861 92 tempitem.wpn10 = 0;
8862 92 break;
8863 }
8864 case itype_crossscroll:
8865 {
8866 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8867 92 tempitem.misc1 = 0;
8868 92 tempitem.misc2 = 0;
8869 92 tempitem.misc3 = 0;
8870 92 tempitem.misc4 = 0;
8871 92 tempitem.misc5 = 0;
8872 92 tempitem.misc6 = 0;
8873 92 tempitem.misc7 = 0;
8874 92 tempitem.misc8 = 0;
8875 92 tempitem.misc9 = 0;
8876 92 tempitem.misc10 = 0;
8877 92 tempitem.wpn = 0;
8878 92 tempitem.wpn2 = 0;
8879 92 tempitem.wpn3 = 0;
8880 92 tempitem.wpn4 = 0;
8881 92 tempitem.wpn5 = 0;
8882 92 tempitem.wpn6 = 0;
8883 92 tempitem.wpn7 = 0;
8884 92 tempitem.wpn8 = 0;
8885 92 tempitem.wpn9 = 0;
8886 92 tempitem.wpn10 = 0;
8887 92 break;
8888 }
8889 case itype_quakescroll:
8890 {
8891 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8892 92 tempitem.misc3 = 0;
8893 92 tempitem.misc4 = 0;
8894 92 tempitem.misc5 = 0;
8895 92 tempitem.misc6 = 0;
8896 92 tempitem.misc7 = 0;
8897 92 tempitem.misc8 = 0;
8898 92 tempitem.misc9 = 0;
8899 92 tempitem.misc10 = 0;
8900 92 tempitem.wpn = 0;
8901 92 tempitem.wpn2 = 0;
8902 92 tempitem.wpn3 = 0;
8903 92 tempitem.wpn4 = 0;
8904 92 tempitem.wpn5 = 0;
8905 92 tempitem.wpn6 = 0;
8906 92 tempitem.wpn7 = 0;
8907 92 tempitem.wpn8 = 0;
8908 92 tempitem.wpn9 = 0;
8909 92 tempitem.wpn10 = 0;
8910 92 break;
8911 }
8912 case itype_whispring:
8913 {
8914 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8915 185 tempitem.misc2 = 0;
8916 185 tempitem.misc3 = 0;
8917 185 tempitem.misc4 = 0;
8918 185 tempitem.misc5 = 0;
8919 185 tempitem.misc6 = 0;
8920 185 tempitem.misc7 = 0;
8921 185 tempitem.misc8 = 0;
8922 185 tempitem.misc9 = 0;
8923 185 tempitem.misc10 = 0;
8924 185 tempitem.wpn = 0;
8925 185 tempitem.wpn2 = 0;
8926 185 tempitem.wpn3 = 0;
8927 185 tempitem.wpn4 = 0;
8928 185 tempitem.wpn5 = 0;
8929 185 tempitem.wpn6 = 0;
8930 185 tempitem.wpn7 = 0;
8931 185 tempitem.wpn8 = 0;
8932 185 tempitem.wpn9 = 0;
8933 185 tempitem.wpn10 = 0;
8934 185 break;
8935 }
8936 case itype_chargering:
8937 {
8938 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8939 184 tempitem.misc3 = 0;
8940 184 tempitem.misc4 = 0;
8941 184 tempitem.misc5 = 0;
8942 184 tempitem.misc6 = 0;
8943 184 tempitem.misc7 = 0;
8944 184 tempitem.misc8 = 0;
8945 184 tempitem.misc9 = 0;
8946 184 tempitem.misc10 = 0;
8947 184 tempitem.wpn = 0;
8948 184 tempitem.wpn2 = 0;
8949 184 tempitem.wpn3 = 0;
8950 184 tempitem.wpn4 = 0;
8951 184 tempitem.wpn5 = 0;
8952 184 tempitem.wpn6 = 0;
8953 184 tempitem.wpn7 = 0;
8954 184 tempitem.wpn8 = 0;
8955 184 tempitem.wpn9 = 0;
8956 184 tempitem.wpn10 = 0;
8957 184 break;
8958 }
8959 case itype_perilscroll:
8960 {
8961 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8962 92 tempitem.misc2 = 0;
8963 92 tempitem.misc3 = 0;
8964 92 tempitem.misc4 = 0;
8965 92 tempitem.misc5 = 0;
8966 92 tempitem.misc6 = 0;
8967 92 tempitem.misc7 = 0;
8968 92 tempitem.misc8 = 0;
8969 92 tempitem.misc9 = 0;
8970 92 tempitem.misc10 = 0;
8971 92 tempitem.wpn = 0;
8972 92 tempitem.wpn2 = 0;
8973 92 tempitem.wpn3 = 0;
8974 92 tempitem.wpn4 = 0;
8975 92 tempitem.wpn5 = 0;
8976 92 tempitem.wpn6 = 0;
8977 92 tempitem.wpn7 = 0;
8978 92 tempitem.wpn8 = 0;
8979 92 tempitem.wpn9 = 0;
8980 92 tempitem.wpn10 = 0;
8981 92 break;
8982 }
8983 case itype_wealthmedal:
8984 {
8985 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8986 277 tempitem.misc2 = 0;
8987 277 tempitem.misc3 = 0;
8988 277 tempitem.misc4 = 0;
8989 277 tempitem.misc5 = 0;
8990 277 tempitem.misc6 = 0;
8991 277 tempitem.misc7 = 0;
8992 277 tempitem.misc8 = 0;
8993 277 tempitem.misc9 = 0;
8994 277 tempitem.misc10 = 0;
8995 277 tempitem.wpn = 0;
8996 277 tempitem.wpn2 = 0;
8997 277 tempitem.wpn3 = 0;
8998 277 tempitem.wpn4 = 0;
8999 277 tempitem.wpn5 = 0;
9000 277 tempitem.wpn6 = 0;
9001 277 tempitem.wpn7 = 0;
9002 277 tempitem.wpn8 = 0;
9003 277 tempitem.wpn9 = 0;
9004 277 tempitem.wpn10 = 0;
9005 277 break;
9006 }
9007 case itype_heartring:
9008 {
9009 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9010 278 tempitem.misc3 = 0;
9011 278 tempitem.misc4 = 0;
9012 278 tempitem.misc5 = 0;
9013 278 tempitem.misc6 = 0;
9014 278 tempitem.misc7 = 0;
9015 278 tempitem.misc8 = 0;
9016 278 tempitem.misc9 = 0;
9017 278 tempitem.misc10 = 0;
9018 278 tempitem.wpn = 0;
9019 278 tempitem.wpn2 = 0;
9020 278 tempitem.wpn3 = 0;
9021 278 tempitem.wpn4 = 0;
9022 278 tempitem.wpn5 = 0;
9023 278 tempitem.wpn6 = 0;
9024 278 tempitem.wpn7 = 0;
9025 278 tempitem.wpn8 = 0;
9026 278 tempitem.wpn9 = 0;
9027 278 tempitem.wpn10 = 0;
9028 278 break;
9029 }
9030 case itype_magicring:
9031 {
9032 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9033 372 tempitem.misc3 = 0;
9034 372 tempitem.misc4 = 0;
9035 372 tempitem.misc5 = 0;
9036 372 tempitem.misc6 = 0;
9037 372 tempitem.misc7 = 0;
9038 372 tempitem.misc8 = 0;
9039 372 tempitem.misc9 = 0;
9040 372 tempitem.misc10 = 0;
9041 372 tempitem.wpn = 0;
9042 372 tempitem.wpn2 = 0;
9043 372 tempitem.wpn3 = 0;
9044 372 tempitem.wpn4 = 0;
9045 372 tempitem.wpn5 = 0;
9046 372 tempitem.wpn6 = 0;
9047 372 tempitem.wpn7 = 0;
9048 372 tempitem.wpn8 = 0;
9049 372 tempitem.wpn9 = 0;
9050 372 tempitem.wpn10 = 0;
9051 372 break;
9052 }
9053 case itype_spinscroll2:
9054 {
9055 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9056 92 tempitem.misc2 = 0;
9057 92 tempitem.misc3 = 0;
9058 92 tempitem.misc4 = 0;
9059 92 tempitem.misc5 = 0;
9060 92 tempitem.misc6 = 0;
9061 92 tempitem.misc7 = 0;
9062 92 tempitem.misc8 = 0;
9063 92 tempitem.misc9 = 0;
9064 92 tempitem.misc10 = 0;
9065 92 tempitem.wpn = 0;
9066 92 tempitem.wpn2 = 0;
9067 92 tempitem.wpn3 = 0;
9068 92 tempitem.wpn4 = 0;
9069 92 tempitem.wpn5 = 0;
9070 92 tempitem.wpn6 = 0;
9071 92 tempitem.wpn7 = 0;
9072 92 tempitem.wpn8 = 0;
9073 92 tempitem.wpn9 = 0;
9074 92 tempitem.wpn10 = 0;
9075 92 break;
9076 }
9077 case itype_quakescroll2:
9078 {
9079 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9080 92 tempitem.misc3 = 0;
9081 92 tempitem.misc4 = 0;
9082 92 tempitem.misc5 = 0;
9083 92 tempitem.misc6 = 0;
9084 92 tempitem.misc7 = 0;
9085 92 tempitem.misc8 = 0;
9086 92 tempitem.misc9 = 0;
9087 92 tempitem.misc10 = 0;
9088 92 tempitem.wpn = 0;
9089 92 tempitem.wpn2 = 0;
9090 92 tempitem.wpn3 = 0;
9091 92 tempitem.wpn4 = 0;
9092 92 tempitem.wpn5 = 0;
9093 92 tempitem.wpn6 = 0;
9094 92 tempitem.wpn7 = 0;
9095 92 tempitem.wpn8 = 0;
9096 92 tempitem.wpn9 = 0;
9097 92 tempitem.wpn10 = 0;
9098 92 break;
9099 }
9100 case itype_agony:
9101 {
9102 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9103 92 tempitem.misc2 = 0;
9104 92 tempitem.misc3 = 0;
9105 92 tempitem.misc4 = 0;
9106 92 tempitem.misc5 = 0;
9107 92 tempitem.misc6 = 0;
9108 92 tempitem.misc7 = 0;
9109 92 tempitem.misc8 = 0;
9110 92 tempitem.misc9 = 0;
9111 92 tempitem.misc10 = 0;
9112 92 tempitem.wpn = 0;
9113 92 tempitem.wpn2 = 0;
9114 92 tempitem.wpn3 = 0;
9115 92 tempitem.wpn4 = 0;
9116 92 tempitem.wpn5 = 0;
9117 92 tempitem.wpn6 = 0;
9118 92 tempitem.wpn7 = 0;
9119 92 tempitem.wpn8 = 0;
9120 92 tempitem.wpn9 = 0;
9121 92 tempitem.wpn10 = 0;
9122 92 break;
9123 }
9124 case itype_stompboots:
9125 {
9126 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9127 92 tempitem.misc1 = 0;
9128 92 tempitem.misc2 = 0;
9129 92 tempitem.misc3 = 0;
9130 92 tempitem.misc4 = 0;
9131 92 tempitem.misc5 = 0;
9132 92 tempitem.misc6 = 0;
9133 92 tempitem.misc7 = 0;
9134 92 tempitem.misc8 = 0;
9135 92 tempitem.misc9 = 0;
9136 92 tempitem.misc10 = 0;
9137 92 tempitem.wpn = 0;
9138 92 tempitem.wpn2 = 0;
9139 92 tempitem.wpn3 = 0;
9140 92 tempitem.wpn4 = 0;
9141 92 tempitem.wpn5 = 0;
9142 92 tempitem.wpn6 = 0;
9143 92 tempitem.wpn7 = 0;
9144 92 tempitem.wpn8 = 0;
9145 92 tempitem.wpn9 = 0;
9146 92 tempitem.wpn10 = 0;
9147 92 break;
9148 }
9149 case itype_whimsicalring:
9150 {
9151 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9152 92 tempitem.misc2 = 0;
9153 92 tempitem.misc3 = 0;
9154 92 tempitem.misc4 = 0;
9155 92 tempitem.misc5 = 0;
9156 92 tempitem.misc6 = 0;
9157 92 tempitem.misc7 = 0;
9158 92 tempitem.misc8 = 0;
9159 92 tempitem.misc9 = 0;
9160 92 tempitem.misc10 = 0;
9161 92 tempitem.wpn = 0;
9162 92 tempitem.wpn2 = 0;
9163 92 tempitem.wpn3 = 0;
9164 92 tempitem.wpn4 = 0;
9165 92 tempitem.wpn5 = 0;
9166 92 tempitem.wpn6 = 0;
9167 92 tempitem.wpn7 = 0;
9168 92 tempitem.wpn8 = 0;
9169 92 tempitem.wpn9 = 0;
9170 92 tempitem.wpn10 = 0;
9171 92 break;
9172 }
9173 case itype_perilring:
9174 {
9175 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9176 93 tempitem.misc2 = 0;
9177 93 tempitem.misc3 = 0;
9178 93 tempitem.misc4 = 0;
9179 93 tempitem.misc5 = 0;
9180 93 tempitem.misc6 = 0;
9181 93 tempitem.misc7 = 0;
9182 93 tempitem.misc8 = 0;
9183 93 tempitem.misc9 = 0;
9184 93 tempitem.misc10 = 0;
9185 93 tempitem.wpn = 0;
9186 93 tempitem.wpn2 = 0;
9187 93 tempitem.wpn3 = 0;
9188 93 tempitem.wpn4 = 0;
9189 93 tempitem.wpn5 = 0;
9190 93 tempitem.wpn6 = 0;
9191 93 tempitem.wpn7 = 0;
9192 93 tempitem.wpn8 = 0;
9193 93 tempitem.wpn9 = 0;
9194 93 tempitem.wpn10 = 0;
9195 93 break;
9196 }
9197 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9198 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9199 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9200 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9201 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9202 {
9203 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9204 2541 tempitem.misc1 = 0;
9205 2541 tempitem.misc2 = 0;
9206 2541 tempitem.misc3 = 0;
9207 2541 tempitem.misc4 = 0;
9208 2541 tempitem.misc5 = 0;
9209 2541 tempitem.misc6 = 0;
9210 2541 tempitem.misc7 = 0;
9211 2541 tempitem.misc8 = 0;
9212 2541 tempitem.misc9 = 0;
9213 2541 tempitem.misc10 = 0;
9214 2541 tempitem.wpn = 0;
9215 2541 tempitem.wpn2 = 0;
9216 2541 tempitem.wpn3 = 0;
9217 2541 tempitem.wpn4 = 0;
9218 2541 tempitem.wpn5 = 0;
9219 2541 tempitem.wpn6 = 0;
9220 2541 tempitem.wpn7 = 0;
9221 2541 tempitem.wpn8 = 0;
9222 2541 tempitem.wpn9 = 0;
9223 2541 tempitem.wpn10 = 0;
9224 2541 break;
9225 }
9226 }
9227 23808 }
9228 //Port quest rules to items
9229
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version <= 31)
9230 {
9231
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9232 {
9233
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9234 90 else tempitem.flags &= ~ ITEM_FLAG2;
9235 107 }
9236
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9237 {
9238
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9239 75 else tempitem.flags &= ~ ITEM_FLAG2;
9240 92 }
9241
9242
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9243 {
9244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9245 277 else tempitem.flags &= ~ ITEM_FLAG4;
9246 277 }
9247
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9248 {
9249
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9250 105 else tempitem.flags &= ~ ITEM_FLAG3;
9251 107 }
9252 23808 }
9253
9254 //Port quest rules to items
9255
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version <= 37)
9256 {
9257
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9258 {
9259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9260 93 else tempitem.flags &= ~ ITEM_FLAG1;
9261 93 }
9262
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9263 {
9264
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9265 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9266 7811 }
9267
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9268 {
9269
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9270 104 else tempitem.flags &= ~ ITEM_FLAG5;
9271 107 }
9272
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9273 {
9274 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9275
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9276 257 else tempitem.flags &= ~ ITEM_FLAG3;
9277 329 }
9278 23808 }
9279
9280
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 38)
9281 {
9282
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9283 {
9284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9285 461 else tempitem.flags &= ~ITEM_FLAG4;
9286
9287
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9288 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9289 461 }
9290
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9291 {
9292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9293 274 else tempitem.flags &= ~ITEM_FLAG4;
9294
9295
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9296 270 else tempitem.flags |= ITEM_FLAG2;
9297 274 }
9298 23808 }
9299
9300
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 39)
9301 {
9302
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9303 {
9304
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9305 409 else tempitem.flags &= ~ITEM_FLAG5;
9306 421 }
9307
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9308 {
9309
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9310 {
9311 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9312 24 }
9313 else
9314 {
9315 159 tempitem.flags |= ITEM_FLAG3;
9316
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9317 74 else tempitem.flags &= ~ITEM_FLAG4;
9318 }
9319 183 }
9320
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9321 {
9322
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9323 {
9324 30 tempitem.flags |= ITEM_FLAG3;
9325
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9326 24 else tempitem.flags &= ~ITEM_FLAG4;
9327 30 }
9328 else
9329 {
9330 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9331 }
9332 184 }
9333 23808 }
9334
9335
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 40)
9336 {
9337
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9338 {
9339
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9340 348 else tempitem.flags &= ~ITEM_FLAG1;
9341 395 }
9342
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9343 {
9344
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9345 8151 else tempitem.flags &= ~ITEM_FLAG8;
9346 8232 }
9347
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9348 {
9349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9350 8011 else tempitem.flags &= ~ITEM_FLAG7;
9351 8011 }
9352
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9353 {
9354 92 tempitem.flags |= ITEM_FLAG7;
9355 92 }
9356 23808 }
9357
9358
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 41 )
9359 {
9360
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9361 {
9362
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9363 7742 else tempitem.flags &= ~ITEM_FLAG9;
9364
9365
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9366 7742 else tempitem.flags &= ~ITEM_FLAG10;
9367 7811 }
9368 23808 }
9369
9370
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 42 )
9371 {
9372
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9373 {
9374
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9375 105 else tempitem.flags &= ~ITEM_FLAG3;
9376
9377 107 tempitem.flags &= ~ITEM_FLAG6;
9378 107 }
9379
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9380 {
9381 93 tempitem.flags &= ~ITEM_FLAG3;
9382 93 }
9383
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9384 {
9385 92 tempitem.flags |= ITEM_FLAG3;
9386
9387 92 tempitem.flags &= ~ITEM_FLAG6;
9388 92 }
9389
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9390 {
9391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9392 7811 else tempitem.flags &= ~ITEM_FLAG6;
9393 7811 }
9394 23808 }
9395
9396
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 43 )
9397 {
9398
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9399 {
9400
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9401 135 else tempitem.flags &= ~ITEM_FLAG3;
9402 138 }
9403 23808 }
9404
9405
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 45 )
9406 {
9407
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9408 {
9409 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9410 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9411 93 }
9412 23808 }
9413
9414
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 46 )
9415 {
9416
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9417 {
9418 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9419 92 }
9420 23808 }
9421
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if ( s_version < 34 ) //! set the default counter for older quests.
9422 {
9423
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9424 {
9425 75 tempitem.cost_counter[0] = 1;
9426 75 }
9427 else
9428 {
9429
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9430 4608 tempitem.cost_counter[0] = 4;
9431 else
9432 {
9433 19125 tempitem.cost_amount[0] = 0;
9434 19125 tempitem.cost_counter[0] = -1;
9435 }
9436 }
9437 23808 }
9438
9439
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if ( s_version < 35 ) //new Lens of Truth flags
9440 {
9441
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9442 {
9443
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9444 {
9445 3 tempitem.flags |= ITEM_FLAG4;
9446 3 }
9447
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9448 {
9449 52 tempitem.flags |= ITEM_FLAG1;
9450 52 }
9451
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9452 {
9453 4 tempitem.flags |= ITEM_FLAG5;
9454 4 }
9455 92 }
9456 23808 }
9457
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9458 {
9459
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9460 {
9461 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9462 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9463 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9464 190464 tempitem.sprite_initiald[q] = 0;
9465 190464 }
9466
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9467 23808 tempitem.sprite_script = 0;
9468 23808 }
9469
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9470 {
9471 23808 tempitem.pickupflag = 0;
9472 23808 }
9473
9474
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 51 )
9475 {
9476
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9477 {
9478 222 tempitem.misc4 = 50; //Step speed
9479 222 }
9480 23808 }
9481
9482
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if( s_version < 52 )
9483 {
9484
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9485 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9486 23808 }
9487
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 23808 times.
33280 if(s_version < 53)
9488 {
9489
4/4
✓ Branch 0 taken 23335 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9490 {
9491 case itype_arrow:
9492 274 tempitem.cost_counter[1] = crARROWS;
9493 274 tempitem.cost_amount[1] = 1;
9494 274 break;
9495 case itype_bomb:
9496 107 tempitem.cost_counter[1] = crBOMBS;
9497 107 tempitem.cost_amount[1] = 1;
9498 107 break;
9499 case itype_sbomb:
9500 92 tempitem.cost_counter[1] = crSBOMBS;
9501 92 tempitem.cost_amount[1] = 1;
9502 92 break;
9503 default:
9504 23335 tempitem.cost_counter[1] = crNONE;
9505 23335 tempitem.cost_amount[1] = 0;
9506 23335 }
9507 23808 tempitem.magiccosttimer[1] = 0;
9508 23808 }
9509
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 24832 times.
33280 if( s_version < 54 )
9510 {
9511
2/2
✓ Branch 0 taken 24735 times.
✓ Branch 1 taken 97 times.
24832 if( tempitem.family == itype_flippers )
9512 97 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9513 24832 }
9514
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 24832 times.
33280 if(s_version < 55)
9515 {
9516
3/3
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 24448 times.
24832 switch(tempitem.family)
9517 {
9518 case itype_spinscroll:
9519 case itype_quakescroll:
9520 192 tempitem.usesound2 = WAV_ZN1CHARGE;
9521 192 break;
9522 case itype_spinscroll2:
9523 case itype_quakescroll2:
9524 192 tempitem.usesound2 = WAV_ZN1CHARGE2;
9525 192 break;
9526 }
9527 24832 }
9528
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 24832 times.
33280 if(s_version < 56)
9529 {
9530
4/4
✓ Branch 0 taken 24395 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 230 times.
✓ Branch 3 taken 111 times.
24832 switch(tempitem.family)
9531 {
9532 case itype_divinefire:
9533
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 4 times.
96 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9534
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 80 times.
96 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9535 96 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9536 96 break;
9537 case itype_candle:
9538
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 119 times.
230 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9539 230 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9540 230 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9541 230 break;
9542 case itype_book:
9543 111 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9544 111 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9545 111 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9546 111 break;
9547 }
9548 24832 }
9549
9550
2/2
✓ Branch 0 taken 31136 times.
✓ Branch 1 taken 2144 times.
33280 if(tempitem.fam_type==0) // Always do this
9551 2144 tempitem.fam_type=1;
9552
9553 33280 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9554 33280 }
9555
9556 130 return 0;
9557 130 }
9558
9559 static bool did_init_def_items = false;
9560 66752 void init_def_items()
9561 {
9562
2/2
✓ Branch 0 taken 66636 times.
✓ Branch 1 taken 116 times.
66752 if(did_init_def_items) return;
9563 116 did_init_def_items = true;
9564 116 default_items[3].cost_counter[1] = crBOMBS;
9565 116 default_items[13].cost_counter[1] = crARROWS;
9566 116 default_items[14].cost_counter[1] = crARROWS;
9567 116 default_items[48].cost_counter[1] = crSBOMBS;
9568 116 default_items[57].cost_counter[1] = crARROWS;
9569 66752 }
9570 66752 void reset_itembuf(itemdata *item, int32_t id)
9571 {
9572 66752 init_def_items();
9573
2/2
✓ Branch 0 taken 28476 times.
✓ Branch 1 taken 38276 times.
66752 if(id<iLast)
9574 {
9575 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9576 38276 word tile = item->tile;
9577 38276 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9578 38276 int32_t ltm = item->ltm;
9579
9580 38276 memcpy(item,&default_items[id],sizeof(itemdata));
9581 38276 item->tile = tile;
9582 38276 item->misc_flags = miscs;
9583 38276 item->csets = cset;
9584 38276 item->frames = frames;
9585 38276 item->speed = speed;
9586 38276 item->delay = delay;
9587 38276 item->ltm = ltm;
9588 38276 }
9589 66752 }
9590
9591 33792 void reset_itemname(int32_t id)
9592 {
9593 33792 sprintf(item_string[id],"zz%03d",id);
9594
9595
2/2
✓ Branch 0 taken 14916 times.
✓ Branch 1 taken 18876 times.
33792 if(id < iLast)
9596 18876 strcpy(item_string[id],old_item_string[id]);
9597 33792 }
9598
9599 130 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9600 {
9601
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9602
9603 130 word weapons_to_read=MAXWPNS;
9604 int32_t dummy;
9605 byte padding;
9606 wpndata tempweapon;
9607 130 word s_version=0, s_cversion=0;
9608
9609
9610
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(Header->zelda_version < 0x186)
9611 {
9612 weapons_to_read=64;
9613 }
9614
9615
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(Header->zelda_version < 0x185)
9616 {
9617 weapons_to_read=32;
9618 }
9619
9620
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
9621 {
9622 126 weapons_to_read=0;
9623
9624 //section version info
9625
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
9626 {
9627 return qe_invalid;
9628 }
9629
9630 126 FFCore.quest_format[vWeaponSprites] = s_version;
9631
9632 //al_trace("Weapons version %d\n", s_version);
9633
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_cversion,f))
9634 {
9635 return qe_invalid;
9636 }
9637
9638 //section size
9639
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
9640 {
9641 return qe_invalid;
9642 }
9643
9644 //finally... section data
9645
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&weapons_to_read,f))
9646 {
9647 return qe_invalid;
9648 }
9649
9650
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9651 {
9652 return qe_invalid;
9653 }
9654 126 }
9655
9656
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version>2)
9657 {
9658
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<weapons_to_read; i++)
9659 {
9660 char tempname[64];
9661
9662
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if(!pfread(tempname, 64, f))
9663 {
9664 return qe_invalid;
9665 }
9666
9667 29184 weapon_string[i][0] = '\0';
9668 29184 strncat(weapon_string[i], tempname, 64 - 1);
9669 29184 }
9670
9671
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version<4)
9672 {
9673 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9674 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9675 }
9676
9677
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version<5)
9678 {
9679 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9680 }
9681
9682 /*
9683 if (s_version<6)
9684 {
9685 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9686 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9687 }
9688 */
9689 114 }
9690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if (!should_skip)
9691 {
9692
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9693 4096 reset_weaponname(i);
9694 16 }
9695
9696
2/2
✓ Branch 0 taken 31024 times.
✓ Branch 1 taken 130 times.
31154 for(int32_t i=0; i<weapons_to_read; i++)
9697 {
9698 31024 word oldtile = 0;
9699
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 22064 times.
31024 if (s_version < 8)
9700 {
9701
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9702 return qe_invalid;
9703 22064 }
9704
9705
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.misc,f))
9706 {
9707 return qe_invalid;
9708 }
9709
9710
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.csets,f))
9711 {
9712 return qe_invalid;
9713 }
9714
9715
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.frames,f))
9716 {
9717 return qe_invalid;
9718 }
9719
9720
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.speed,f))
9721 {
9722 return qe_invalid;
9723 }
9724
9725
1/2
✓ Branch 0 taken 31024 times.
✗ Branch 1 not taken.
31024 if(!p_getc(&tempweapon.type,f))
9726 {
9727 return qe_invalid;
9728 }
9729
9730
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 9472 times.
31024 if ( s_version >= 7 )
9731 {
9732
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetw(&tempweapon.script,f))
9733 {
9734 return qe_invalid;
9735 }
9736
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if(!p_igetl(&tempweapon.tile,f))
9737 {
9738 return qe_invalid;
9739 }
9740 9472 }
9741
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 21552 times.
31024 if ( s_version < 7 )
9742 {
9743 21552 tempweapon.tile = oldtile;
9744 21552 }
9745
9746
2/2
✓ Branch 0 taken 30000 times.
✓ Branch 1 taken 1024 times.
31024 if(Header->zelda_version < 0x193)
9747 {
9748
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9749 {
9750 return qe_invalid;
9751 }
9752 1024 }
9753
9754
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 1840 times.
31024 if(s_version < 6)
9755 {
9756
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9757 {
9758 4 tempweapon.misc |= WF_BEHIND;
9759 4 }
9760 else
9761 1836 tempweapon.misc &= ~WF_BEHIND;
9762 1840 }
9763
9764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31024 times.
31024 if (!should_skip)
9765 31024 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9766 31024 }
9767
9768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (should_skip)
9769 return 0;
9770
9771
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<2)
9772 {
9773 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9774 16 }
9775
9776
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(s_version<5)
9777 {
9778 16 wpnsbuf[iwQuarterHearts].tile=1;
9779 16 wpnsbuf[iwQuarterHearts].csets=1;
9780 16 }
9781
9782
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(Header->zelda_version < 0x176)
9783 {
9784 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9785 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9786 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9787 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9788 }
9789
9790
2/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
130 if((Header->zelda_version < 0x192)||
9791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9792 {
9793 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9794 4 }
9795
9796
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if((Header->zelda_version < 0x210))
9797 {
9798 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9799 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9800 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9801 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9802 4 }
9803
9804 130 return 0;
9805 130 }
9806
9807 130 void init_guys(int32_t guyversion)
9808 {
9809
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<MAXGUYS; i++)
9810 {
9811 66560 guysbuf[i] = default_guys[0];
9812 66560 }
9813
9814
2/2
✓ Branch 0 taken 23010 times.
✓ Branch 1 taken 130 times.
23140 for(int32_t i=0; i<OLDMAXGUYS; i++)
9815 {
9816 23010 guysbuf[i] = default_guys[i];
9817
2/2
✓ Branch 0 taken 22750 times.
✓ Branch 1 taken 260 times.
23010 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9818 23010 guysbuf[i].spr_death = iwDeath;
9819 23010 guysbuf[i].spr_spawn = iwSpawn;
9820 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9821
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 20178 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
23010 if(guyversion<=3 && i==ePATRABS)
9822 {
9823 16 guysbuf[i].bosspal=spDIG;
9824 16 guysbuf[i].cset=14;
9825 16 guysbuf[i].misc9=14;
9826 16 }
9827
9828
2/2
✓ Branch 0 taken 20178 times.
✓ Branch 1 taken 2832 times.
23010 if(guyversion<=3)
9829 {
9830 // Rope/Ghini Flash rules
9831
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9832 {
9833
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9834 {
9835 12 guysbuf[i].flags2 &= ~guy_flashing;
9836 12 }
9837 2124 }
9838
9839
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9840 {
9841
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9842 {
9843 18 guysbuf[i].flags2 &= ~guy_flashing;
9844 18 }
9845 531 }
9846
9847
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9848 {
9849
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9850 {
9851 3 guysbuf[i].flags2 |= guy_blinking;
9852 3 }
9853
9854
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9855 {
9856 guysbuf[i].flags2 |= guy_transparent;
9857 }
9858 16 }
9859 2832 }
9860
9861 // Darknut fix
9862
10/10
✓ Branch 0 taken 22880 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 22750 times.
✓ Branch 3 taken 130 times.
✓ Branch 4 taken 22620 times.
✓ Branch 5 taken 130 times.
✓ Branch 6 taken 22490 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 130 times.
✓ Branch 9 taken 22360 times.
23010 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9863 {
9864
2/2
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 210 times.
650 if(get_qr(qr_NEWENEMYTILES))
9865 {
9866 440 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9867 440 guysbuf[i].s_width=guysbuf[i].e_width;
9868 440 guysbuf[i].s_height=guysbuf[i].e_height;
9869 440 }
9870 210 else guysbuf[i].s_tile=860;
9871
9872
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 80 times.
650 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9873 {
9874 80 guysbuf[i].flags |= guy_bkshield;
9875 80 }
9876 650 }
9877
9878
4/4
✓ Branch 0 taken 22880 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 23002 times.
✓ Branch 3 taken 8 times.
23010 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9879 {
9880 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9881 8 }
9882 23010 }
9883 130 }
9884
9885 4096 void reset_weaponname(int32_t i)
9886 {
9887
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9888 {
9889 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9890 1408 }
9891 else
9892 2688 sprintf(weapon_string[i],"zz%03d",i);
9893 4096 }
9894
9895 130 void init_item_drop_sets()
9896 {
9897
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9898 {
9899 // item_drop_sets[i] = default_item_drop_sets[0];
9900 33280 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9901 33280 }
9902
9903
2/2
✓ Branch 0 taken 1690 times.
✓ Branch 1 taken 130 times.
1820 for(int32_t i=0; i<isMAX; i++)
9904 {
9905 1690 item_drop_sets[i] = default_item_drop_sets[i];
9906
9907 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9908
2/2
✓ Branch 0 taken 16900 times.
✓ Branch 1 taken 1690 times.
18590 for(int32_t j=0; j<10; ++j)
9909 {
9910 16900 int32_t it = item_drop_sets[i].item[j];
9911
9912
3/4
✓ Branch 0 taken 11868 times.
✓ Branch 1 taken 5032 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 762 times.
16900 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9913
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 11106 times.
11868 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9914 {
9915 762 item_drop_sets[i].chance[j+1]=0;
9916 762 }
9917
3/4
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 15618 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 520 times.
16138 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9918 {
9919 item_drop_sets[i].chance[j+1]=0;
9920 }
9921
9922 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9923
2/2
✓ Branch 0 taken 16892 times.
✓ Branch 1 taken 8 times.
16900 if(itemsbuf[it].family == itype_misc)
9924 {
9925 // If a non-gameplay item was selected, then item drop was aborted.
9926 // Reflect this by increasing the 'Nothing' chance accordingly.
9927 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9928 8 item_drop_sets[i].chance[j+1]=0;
9929 8 }
9930 16900 }
9931 1690 }
9932 130 }
9933
9934 130 void init_favorites()
9935 {
9936
2/2
✓ Branch 0 taken 163800 times.
✓ Branch 1 taken 130 times.
163930 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9937 {
9938 163800 favorite_combos[i]=-1;
9939 163800 }
9940 130 }
9941
9942 const char *ctype_name[cMAX]=
9943 {
9944 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9945 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9946 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9947 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9948 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9949 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9950 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9951 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9952 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9953 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9954 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9955 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9956 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9957 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9958 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9959 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9960 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9961 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9962 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9963 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9964 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9965 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9966 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9967 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9968 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9969 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9970 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9971 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9972
9973 };
9974
9975 225 int32_t init_combo_classes()
9976 {
9977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
225 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9978
2/2
✓ Branch 0 taken 41175 times.
✓ Branch 1 taken 225 times.
41400 for(int32_t i=0; i<cMAX; i++)
9979 {
9980 41175 combo_class_buf[i] = default_combo_classes[i];
9981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41175 times.
41175 if ( char const* nm = zi->getComboTypeName(i) )
9982 {
9983 41175 size_t len = strlen(nm);
9984
2/2
✓ Branch 0 taken 2635200 times.
✓ Branch 1 taken 41175 times.
2676375 for ( size_t q = 0; q < 64; q++ )
9985 {
9986
2/2
✓ Branch 0 taken 603225 times.
✓ Branch 1 taken 2031975 times.
2635200 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9987 2635200 }
9988 41175 }
9989 41175 }
9990
9991 225 return 0;
9992 }
9993
9994 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9995 {
9996
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 89 times.
97 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if (should_skip) return 0;
9998
9999
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
10000 //these are here to bypass compiler warnings about unused arguments
10001 97 cv_herosprites=cv_herosprites;
10002
10003 97 zinit.hero_swim_speed=67; //default
10004 97 setupherotiles(zinit.heroAnimationStyle);
10005 97 setupherodefenses();
10006 97 setupherooffsets();
10007
10008
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
10009 {
10010 word tile, tile2;
10011 byte flip, extend, dummy_byte;
10012
10013
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10014 {
10015
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10016 {
10017 return qe_invalid;
10018 }
10019
10020
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10021 {
10022 return qe_invalid;
10023 }
10024
10025
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10026 {
10027 return qe_invalid;
10028 }
10029
10030 308 walkspr[i][spr_tile]=(int32_t)tile;
10031 308 walkspr[i][spr_flip]=(int32_t)flip;
10032 308 walkspr[i][spr_extend]=(int32_t)extend;
10033 308 }
10034
10035
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10036 {
10037
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10038 {
10039 return qe_invalid;
10040 }
10041
10042
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10043 {
10044 return qe_invalid;
10045 }
10046
10047
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10048 {
10049 return qe_invalid;
10050 }
10051
10052 308 stabspr[i][spr_tile]=(int32_t)tile;
10053 308 stabspr[i][spr_flip]=(int32_t)flip;
10054 308 stabspr[i][spr_extend]=(int32_t)extend;
10055 308 }
10056
10057
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10058 {
10059
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10060 {
10061 return qe_invalid;
10062 }
10063
10064
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10065 {
10066 return qe_invalid;
10067 }
10068
10069
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10070 {
10071 return qe_invalid;
10072 }
10073
10074 308 slashspr[i][spr_tile]=(int32_t)tile;
10075 308 slashspr[i][spr_flip]=(int32_t)flip;
10076 308 slashspr[i][spr_extend]=(int32_t)extend;
10077 308 }
10078
10079
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10080 {
10081
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10082 {
10083 return qe_invalid;
10084 }
10085
10086
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10087 {
10088 return qe_invalid;
10089 }
10090
10091
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10092 {
10093 return qe_invalid;
10094 }
10095
10096 308 floatspr[i][spr_tile]=(int32_t)tile;
10097 308 floatspr[i][spr_flip]=(int32_t)flip;
10098 308 floatspr[i][spr_extend]=(int32_t)extend;
10099 308 }
10100
10101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
10102 {
10103
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10104 {
10105
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10106 {
10107 return qe_invalid;
10108 }
10109
10110
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10111 {
10112 return qe_invalid;
10113 }
10114
10115
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10116 {
10117 return qe_invalid;
10118 }
10119
10120 308 swimspr[i][spr_tile]=(int32_t)tile;
10121 308 swimspr[i][spr_flip]=(int32_t)flip;
10122 308 swimspr[i][spr_extend]=(int32_t)extend;
10123 308 }
10124 77 }
10125
10126
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10127 {
10128
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10129 {
10130 return qe_invalid;
10131 }
10132
10133
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10134 {
10135 return qe_invalid;
10136 }
10137
10138
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10139 {
10140 return qe_invalid;
10141 }
10142
10143 308 divespr[i][spr_tile]=(int32_t)tile;
10144 308 divespr[i][spr_flip]=(int32_t)flip;
10145 308 divespr[i][spr_extend]=(int32_t)extend;
10146 308 }
10147
10148
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10149 {
10150
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10151 {
10152 return qe_invalid;
10153 }
10154
10155
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10156 {
10157 return qe_invalid;
10158 }
10159
10160
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10161 {
10162 return qe_invalid;
10163 }
10164
10165 308 poundspr[i][spr_tile]=(int32_t)tile;
10166 308 poundspr[i][spr_flip]=(int32_t)flip;
10167 308 poundspr[i][spr_extend]=(int32_t)extend;
10168 308 }
10169
10170
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10171 {
10172 return qe_invalid;
10173 }
10174
10175 77 flip=0;
10176
10177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10178 {
10179
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10180 {
10181 return qe_invalid;
10182 }
10183 77 }
10184
10185
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10186 {
10187 return qe_invalid;
10188 }
10189
10190 77 castingspr[spr_tile]=(int32_t)tile;
10191 77 castingspr[spr_flip]=(int32_t)flip;
10192 77 castingspr[spr_extend]=(int32_t)extend;
10193
10194
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10195 {
10196 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10197
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10198 {
10199
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10200 {
10201
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10202 {
10203 return qe_invalid;
10204 }
10205
10206
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10207 {
10208 return qe_invalid;
10209 }
10210
10211
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10212 {
10213 return qe_invalid;
10214 }
10215
10216 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10217 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10218 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10219 308 }
10220 154 }
10221 77 }
10222 else
10223 {
10224 for(int32_t i=0; i<2; i++)
10225 {
10226 if(!p_igetw(&tile,f))
10227 {
10228 return qe_invalid;
10229 }
10230
10231 if(!p_igetw(&tile2,f))
10232 {
10233 return qe_invalid;
10234 }
10235
10236 if(!p_getc(&extend,f))
10237 {
10238 return qe_invalid;
10239 }
10240
10241 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10242 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10243 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10244 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10245 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10246 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10247 }
10248 }
10249
10250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10251 {
10252
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10253 {
10254
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10255 {
10256 return qe_invalid;
10257 }
10258
10259
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10260 {
10261 return qe_invalid;
10262 }
10263
10264
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10265 {
10266 return qe_invalid;
10267 }
10268
10269 308 jumpspr[i][spr_tile]=(int32_t)tile;
10270 308 jumpspr[i][spr_flip]=(int32_t)flip;
10271 308 jumpspr[i][spr_extend]=(int32_t)extend;
10272 308 }
10273 77 }
10274
10275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10276 {
10277
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10278 {
10279
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10280 {
10281 return qe_invalid;
10282 }
10283
10284
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10285 {
10286 return qe_invalid;
10287 }
10288
10289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_getc(&extend,f))
10290 {
10291 return qe_invalid;
10292 }
10293
10294 308 chargespr[i][spr_tile]=(int32_t)tile;
10295 308 chargespr[i][spr_flip]=(int32_t)flip;
10296 308 chargespr[i][spr_extend]=(int32_t)extend;
10297 308 }
10298 77 }
10299
10300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10301 {
10302
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10303 {
10304 return qe_invalid;
10305 }
10306
10307 77 zinit.hero_swim_speed=(byte)dummy_byte;
10308 77 }
10309
10310 77 memset(frozenspr, 0, sizeof(frozenspr));
10311 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10312 77 memset(onfirespr, 0, sizeof(onfirespr));
10313 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10314 77 memset(diggingspr, 0, sizeof(diggingspr));
10315 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10316 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10317 77 memset(pushingspr, 0, sizeof(pushingspr));
10318 77 memset(liftingspr, 0, sizeof(liftingspr));
10319 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10320 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10321 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10322 77 memset(fallingspr, 0, sizeof(fallingspr));
10323 77 memset(shockedspr, 0, sizeof(shockedspr));
10324 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10325 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10326 77 memset(readingspr, 0, sizeof(readingspr));
10327 77 memset(slash180spr, 0, sizeof(slash180spr));
10328 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10329 77 memset(dashspr, 0, sizeof(dashspr));
10330 77 memset(bonkspr, 0, sizeof(bonkspr));
10331 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10332 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10333 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10334
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10335 {
10336
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10337 {
10338 924 drowningspr[q][p] = divespr[q][p];
10339 924 drowning_lavaspr[q][p] = divespr[q][p];
10340 924 }
10341 308 }
10342 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10343 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10344 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10345 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10346 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10347 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10348 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10349 77 }
10350
10351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10352 {
10353 97 bool fastswim = zinit.hero_swim_speed > 60;
10354 // '2/3' or '1/2'
10355 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10356 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10357 97 }
10358 97 return 0;
10359 97 }
10360
10361 6290 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10362 {
10363 6290 arr[spr_tile] = tile;
10364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6290 times.
6290 arr[spr_flip] = (flip > 3 ? 0 : flip);
10365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6290 times.
6290 arr[spr_extend] = (ext > 2 ? 0 : ext);
10366 6290 }
10367 //Used to read the player sprites as int32_t, not word.
10368 37 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10369 {
10370 //these are here to bypass compiler warnings about unused arguments
10371 37 cv_herosprites=cv_herosprites;
10372
10373 37 zinit.hero_swim_speed=67; //default
10374 37 setupherotiles(zinit.heroAnimationStyle);
10375 37 setupherodefenses();
10376 37 setupherooffsets();
10377
10378 int32_t tile, tile2;
10379 byte flip, extend, dummy_byte;
10380
10381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>=0)
10382 {
10383
10384
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10385 {
10386
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10392 {
10393 return qe_invalid;
10394 }
10395
10396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10397 {
10398 return qe_invalid;
10399 }
10400
10401 148 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10402 148 }
10403
10404
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10405 {
10406
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10407 {
10408 return qe_invalid;
10409 }
10410
10411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10412 {
10413 return qe_invalid;
10414 }
10415
10416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10417 {
10418 return qe_invalid;
10419 }
10420
10421 148 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10422 148 }
10423
10424
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10425 {
10426
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10427 {
10428 return qe_invalid;
10429 }
10430
10431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10432 {
10433 return qe_invalid;
10434 }
10435
10436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10437 {
10438 return qe_invalid;
10439 }
10440
10441 148 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10442 148 }
10443
10444
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10445 {
10446
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10447 {
10448 return qe_invalid;
10449 }
10450
10451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10452 {
10453 return qe_invalid;
10454 }
10455
10456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10457 {
10458 return qe_invalid;
10459 }
10460
10461 148 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10462 148 }
10463
10464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>1)
10465 {
10466
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10467 {
10468
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10469 {
10470 return qe_invalid;
10471 }
10472
10473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10474 {
10475 return qe_invalid;
10476 }
10477
10478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10479 {
10480 return qe_invalid;
10481 }
10482
10483 148 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10484 148 }
10485 37 }
10486
10487
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10488 {
10489
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10490 {
10491 return qe_invalid;
10492 }
10493
10494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10495 {
10496 return qe_invalid;
10497 }
10498
10499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10500 {
10501 return qe_invalid;
10502 }
10503
10504 148 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10505 148 }
10506
10507
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10508 {
10509
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10510 {
10511 return qe_invalid;
10512 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10515 {
10516 return qe_invalid;
10517 }
10518
10519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10520 {
10521 return qe_invalid;
10522 }
10523
10524 148 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10525 148 }
10526
10527
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tile,f))
10528 {
10529 return qe_invalid;
10530 }
10531
10532 37 flip=0;
10533
10534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>0)
10535 {
10536
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&flip,f))
10537 {
10538 return qe_invalid;
10539 }
10540 37 }
10541
10542
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&extend,f))
10543 {
10544 return qe_invalid;
10545 }
10546
10547 37 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10548
10549
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(v_herosprites>0)
10550 {
10551 37 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10552
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 37 times.
111 for(int32_t i=0; i<2; i++)
10553 {
10554
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 74 times.
296 for(int32_t j=0; j<num_holdsprs; j++)
10555 {
10556
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!p_igetl(&tile,f))
10557 {
10558 return qe_invalid;
10559 }
10560
10561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(!p_getc(&flip,f))
10562 {
10563 return qe_invalid;
10564 }
10565
10566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(!p_getc(&extend,f))
10567 {
10568 return qe_invalid;
10569 }
10570
10571 222 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10572 222 }
10573 74 }
10574 37 }
10575 else
10576 {
10577 for(int32_t i=0; i<2; i++)
10578 {
10579 if(!p_igetl(&tile,f))
10580 {
10581 return qe_invalid;
10582 }
10583
10584 if(!p_igetl(&tile2,f))
10585 {
10586 return qe_invalid;
10587 }
10588
10589 if(!p_getc(&extend,f))
10590 {
10591 return qe_invalid;
10592 }
10593
10594 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10595 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10596 }
10597 }
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>2)
10600 {
10601
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10602 {
10603
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10604 {
10605 return qe_invalid;
10606 }
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10609 {
10610 return qe_invalid;
10611 }
10612
10613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10614 {
10615 return qe_invalid;
10616 }
10617
10618 148 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10619 148 }
10620 37 }
10621
10622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>3)
10623 {
10624
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t i=0; i<4; i++)
10625 {
10626
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10627 {
10628 return qe_invalid;
10629 }
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10632 {
10633 return qe_invalid;
10634 }
10635
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10637 {
10638 return qe_invalid;
10639 }
10640
10641 148 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10642 148 }
10643 37 }
10644
10645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(v_herosprites>4)
10646 {
10647
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&dummy_byte,f))
10648 {
10649 return qe_invalid;
10650 }
10651
10652 37 zinit.hero_swim_speed=(byte)dummy_byte;
10653 37 }
10654
10655
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(v_herosprites>6)
10656 {
10657
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10658 {
10659
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10660 return qe_invalid;
10661
10662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10663 return qe_invalid;
10664
10665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10666 return qe_invalid;
10667
10668 148 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10669 148 }
10670
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10671 {
10672
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10673 return qe_invalid;
10674
10675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10676 return qe_invalid;
10677
10678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10679 return qe_invalid;
10680
10681 148 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10682 148 }
10683
10684
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10685 {
10686
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10687 return qe_invalid;
10688
10689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10690 return qe_invalid;
10691
10692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10693 return qe_invalid;
10694
10695 148 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10696 148 }
10697
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10698 {
10699
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10700 return qe_invalid;
10701
10702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10703 return qe_invalid;
10704
10705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10706 return qe_invalid;
10707
10708 148 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10709 148 }
10710
10711
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10712 {
10713
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10714 return qe_invalid;
10715
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10717 return qe_invalid;
10718
10719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10720 return qe_invalid;
10721
10722 148 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10723 148 }
10724
10725
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10726 {
10727
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10728 return qe_invalid;
10729
10730
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10731 return qe_invalid;
10732
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10734 return qe_invalid;
10735
10736 148 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10737 148 }
10738
10739
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10740 {
10741
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10742 return qe_invalid;
10743
10744
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10745 return qe_invalid;
10746
10747
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10748 return qe_invalid;
10749
10750 148 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10751 148 }
10752
10753
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10754 {
10755
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10756 return qe_invalid;
10757
10758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10759 return qe_invalid;
10760
10761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10762 return qe_invalid;
10763
10764 148 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10765 148 }
10766
10767
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10768 {
10769
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10770 return qe_invalid;
10771
10772
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10773 return qe_invalid;
10774
10775
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10776 return qe_invalid;
10777
10778 148 byte frames = 0;
10779
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 140 times.
148 if(v_herosprites > 15)
10780 {
10781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if(!p_getc(&frames,f))
10782 return qe_invalid;
10783 140 }
10784
10785 148 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10786 148 liftingspr[q][spr_frames] = frames;
10787 148 }
10788
10789
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10790 {
10791
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10792 return qe_invalid;
10793
10794
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10795 return qe_invalid;
10796
10797
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10798 return qe_invalid;
10799
10800 148 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10801 148 }
10802
10803
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10804 {
10805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&tile,f))
10806 return qe_invalid;
10807
10808
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10809 return qe_invalid;
10810
10811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10812 return qe_invalid;
10813
10814 148 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10815 148 }
10816
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10817 {
10818
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10819 return qe_invalid;
10820
10821
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10822 return qe_invalid;
10823
10824
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10825 return qe_invalid;
10826
10827 148 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10828 148 }
10829
10830
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10831 {
10832
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10833 return qe_invalid;
10834
10835
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10836 return qe_invalid;
10837
10838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10839 return qe_invalid;
10840
10841 148 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10842 148 }
10843
10844
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10845 {
10846
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10847 return qe_invalid;
10848
10849
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10850 return qe_invalid;
10851
10852
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10853 return qe_invalid;
10854
10855 148 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10856 148 }
10857
10858
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10859 {
10860
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10861 return qe_invalid;
10862
10863
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10864 return qe_invalid;
10865
10866
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10867 return qe_invalid;
10868
10869 148 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10870 148 }
10871
10872
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10873 {
10874
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10878 return qe_invalid;
10879
10880
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10881 return qe_invalid;
10882
10883 148 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10884 148 }
10885
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10886 {
10887
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10888 return qe_invalid;
10889
10890
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10891 return qe_invalid;
10892
10893
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10894 return qe_invalid;
10895
10896 148 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10897 148 }
10898
10899
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10900 {
10901
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10902 return qe_invalid;
10903
10904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
10905 return qe_invalid;
10906
10907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10908 return qe_invalid;
10909
10910 148 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10911 148 }
10912
10913
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10914 {
10915
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10916 return qe_invalid;
10917
10918
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10919 return qe_invalid;
10920
10921
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10922 return qe_invalid;
10923
10924 148 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10925 148 }
10926
10927
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10928 {
10929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&tile,f))
10930 return qe_invalid;
10931
10932
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10933 return qe_invalid;
10934
10935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
10936 return qe_invalid;
10937
10938 148 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10939 148 }
10940
10941
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10942 {
10943
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10944 return qe_invalid;
10945
10946
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10947 return qe_invalid;
10948
10949
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10950 return qe_invalid;
10951
10952 148 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10953 148 }
10954
10955
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10956 {
10957
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10958 return qe_invalid;
10959
10960
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10961 return qe_invalid;
10962
10963
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10964 return qe_invalid;
10965
10966 148 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10967 148 }
10968
10969
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
10970 {
10971
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
10972 return qe_invalid;
10973
10974
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&flip,f))
10975 return qe_invalid;
10976
10977
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_getc(&extend,f))
10978 return qe_invalid;
10979
10980 148 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10981 148 }
10982
10983
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 37 times.
148 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10984 {
10985
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&tile,f))
10986 return qe_invalid;
10987
10988
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&flip,f))
10989 return qe_invalid;
10990
10991
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_getc(&extend,f))
10992 return qe_invalid;
10993
10994 111 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10995 111 }
10996 37 }
10997 else
10998 {
10999 memset(frozenspr, 0, sizeof(frozenspr));
11000 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11001 memset(onfirespr, 0, sizeof(onfirespr));
11002 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11003 memset(diggingspr, 0, sizeof(diggingspr));
11004 memset(usingrodspr, 0, sizeof(usingrodspr));
11005 memset(usingcanespr, 0, sizeof(usingcanespr));
11006 memset(pushingspr, 0, sizeof(pushingspr));
11007 memset(liftingspr, 0, sizeof(liftingspr));
11008 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11009 memset(stunnedspr, 0, sizeof(stunnedspr));
11010 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11011 memset(fallingspr, 0, sizeof(fallingspr));
11012 memset(shockedspr, 0, sizeof(shockedspr));
11013 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11014 memset(pullswordspr, 0, sizeof(pullswordspr));
11015 memset(readingspr, 0, sizeof(readingspr));
11016 memset(slash180spr, 0, sizeof(slash180spr));
11017 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11018 memset(dashspr, 0, sizeof(dashspr));
11019 memset(bonkspr, 0, sizeof(bonkspr));
11020 memset(medallionsprs, 0, sizeof(medallionsprs));
11021 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11022 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11023 for(int32_t q = 0; q < 4; ++q)
11024 {
11025 for(int32_t p = 0; p < 3; ++p)
11026 {
11027 drowningspr[q][p] = divespr[q][p];
11028 drowning_lavaspr[q][p] = divespr[q][p];
11029 }
11030 }
11031 }
11032
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 8)
11033 {
11034
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11035 {
11036
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
11037 return qe_invalid;
11038
11039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
11040 return qe_invalid;
11041
11042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
11043 return qe_invalid;
11044
11045 148 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11046 148 }
11047 37 }
11048 else
11049 {
11050 memset(sideswimspr, 0, sizeof(sideswimspr));
11051 }
11052
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 9)
11053 {
11054
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11055 {
11056
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
11057 return qe_invalid;
11058
11059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
11060 return qe_invalid;
11061
11062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
11063 return qe_invalid;
11064
11065 148 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11066 148 }
11067
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11068 {
11069
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
11070 return qe_invalid;
11071
11072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
11073 return qe_invalid;
11074
11075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
11076 return qe_invalid;
11077
11078 148 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11079 148 }
11080
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11081 {
11082
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
11083 return qe_invalid;
11084
11085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
11086 return qe_invalid;
11087
11088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
11089 return qe_invalid;
11090
11091 148 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11092 148 }
11093
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11094 {
11095
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
11096 return qe_invalid;
11097
11098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
11099 return qe_invalid;
11100
11101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
11102 return qe_invalid;
11103
11104 148 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11105 148 }
11106 37 }
11107 else
11108 {
11109 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11110 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11111 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11112 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11113 }
11114
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 10)
11115 {
11116
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11117 {
11118 int32_t hmr;
11119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_igetl(&hmr,f))
11120 return qe_invalid;
11121
11122 148 hammeroffsets[q] = hmr;
11123 148 }
11124 37 }
11125 else
11126 {
11127 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11128 }
11129
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 11)
11130 {
11131
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 37 times.
148 for(int32_t q = 0; q < 3; ++q)
11132 {
11133
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(!p_igetl(&tile,f))
11134 return qe_invalid;
11135
11136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_getc(&flip,f))
11137 return qe_invalid;
11138
11139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(!p_getc(&extend,f))
11140 return qe_invalid;
11141
11142 111 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11143 111 }
11144 37 }
11145 else
11146 {
11147 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11148 }
11149
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 12)
11150 {
11151
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tile,f))
11152 return qe_invalid;
11153
11154
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&flip,f))
11155 return qe_invalid;
11156
11157
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_getc(&extend,f))
11158 return qe_invalid;
11159 37 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11160
11161 37 }
11162 else
11163 {
11164 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11165 }
11166
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 13)
11167 {
11168
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11169 {
11170
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
11171 return qe_invalid;
11172
11173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
11174 return qe_invalid;
11175
11176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
11177 return qe_invalid;
11178
11179 148 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11180 148 }
11181 37 }
11182 else
11183 {
11184 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11185 }
11186
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 14)
11187 {
11188
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 37 times.
185 for(int32_t q = 0; q < 4; ++q)
11189 {
11190
1/2
✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
148 if(!p_igetl(&tile,f))
11191 return qe_invalid;
11192
11193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&flip,f))
11194 return qe_invalid;
11195
11196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
148 if(!p_getc(&extend,f))
11197 return qe_invalid;
11198
11199 148 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11200 148 }
11201 37 }
11202 else
11203 {
11204 memset(revslashspr, 0, sizeof(revslashspr));
11205 }
11206
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if (v_herosprites > 7)
11207 {
11208 37 int32_t num_defense = wMax;
11209 37 byte def = 0;
11210
11211 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11212 /*if(v_herosprites > [x])
11213 * {
11214 * num_defense = 146 //value of wMax on version 8
11215 * }
11216 */
11217
11218
2/2
✓ Branch 0 taken 5402 times.
✓ Branch 1 taken 37 times.
5439 for (int32_t q = 0; q < num_defense; q++)
11219 {
11220
1/2
✓ Branch 0 taken 5402 times.
✗ Branch 1 not taken.
5402 if (!p_getc(&def, f))
11221 return qe_invalid;
11222
11223 5402 hero_defence[q] = def;
11224 5402 }
11225 37 }
11226 else
11227 {
11228 int32_t num_defense = wMax;
11229 for (int32_t q = 0; q < num_defense; q++)
11230 {
11231 hero_defence[q] = 0;
11232 }
11233 }
11234 37 }
11235
11236
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 4 times.
37 if(FFCore.quest_format[vInitData] < 34)
11237 {
11238 4 bool fastswim = zinit.hero_swim_speed > 60;
11239 // '2/3' or '1/2'
11240 4 zinit.hero_swim_mult = fastswim ? 2 : 1;
11241 4 zinit.hero_swim_div = fastswim ? 3 : 2;
11242 4 }
11243 37 return 0;
11244 37 }
11245
11246
11247 114 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11248 {
11249 //these are here to bypass compiler warnings about unused arguments
11250 114 Header=Header;
11251
11252 dword dummy;
11253 114 word s_version=0, s_cversion=0;
11254
11255 //section version info
11256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
11257 {
11258 return qe_invalid;
11259 }
11260
11261 114 FFCore.quest_format[vHeroSprites] = s_version;
11262
11263 //al_trace("Player sprites version %d\n", s_version);
11264
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
11265 {
11266 return qe_invalid;
11267 }
11268
11269 //section size
11270
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy,f))
11271 {
11272 return qe_invalid;
11273 }
11274
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if ( s_version >= 6 )
11275 {
11276 //al_trace("Reading Player Sprites v6\n");
11277 37 return readherosprites3(f, s_version, dummy);
11278 }
11279 77 else return readherosprites2(f, s_version, dummy);
11280 114 }
11281
11282 85 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11283 {
11284 85 subscreens_active.clear();
11285 85 subscreens_passive.clear();
11286 85 subscreens_overlay.clear();
11287
2/2
✓ Branch 0 taken 10880 times.
✓ Branch 1 taken 85 times.
10965 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11288 {
11289 subscreen_group g;
11290 10880 memset(&g,0,sizeof(subscreen_group));
11291 10880 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10880 times.
10880 if(ret!=0)
11293 return ret;
11294
2/2
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 10487 times.
10880 if(g.objects[0].type == ssoNULL) continue;
11295
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 206 times.
393 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11296 393 ZCSubscreen& sub = vec.emplace_back();
11297 393 sub.load_old(g);
11298 393 }
11299
11300 85 return 0;
11301 85 }
11302
11303 10880 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11304 {
11305 10880 int32_t numsub=0;
11306 10880 byte temp_ss=0;
11307 subscreen_object temp_sub_stack;
11308 10880 subscreen_object *temp_sub = &temp_sub_stack;
11309
11310 char tempname[64];
11311
11312 // FWIW I never saw anything bigger than 20.
11313 #define MAX_DP1_LEN 1024
11314 char tempdp1[MAX_DP1_LEN];
11315
11316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10880 times.
10880 if(!pfread(tempname,64,f))
11317 {
11318 return qe_invalid;
11319 }
11320
11321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10880 times.
10880 if(s_version > 1)
11322 {
11323
1/2
✓ Branch 0 taken 10880 times.
✗ Branch 1 not taken.
10880 if(!p_getc(&temp_ss,f))
11324 {
11325 return qe_invalid;
11326 }
11327 10880 }
11328
11329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10880 times.
10880 if(s_version < 4)
11330 {
11331 uint8_t tmp=0;
11332
11333 if(!p_getc(&tmp,f))
11334 {
11335 return qe_invalid;
11336 }
11337
11338 numsub = (int32_t)tmp;
11339 }
11340 else
11341 {
11342 word tmp;
11343
11344
1/2
✓ Branch 0 taken 10880 times.
✗ Branch 1 not taken.
10880 if(!p_igetw(&tmp, f))
11345 {
11346 return qe_invalid;
11347 }
11348
11349 10880 numsub = (int32_t)tmp;
11350 }
11351
11352 int32_t j;
11353
11354
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24065 times.
✓ Branch 2 taken 13185 times.
✓ Branch 3 taken 10880 times.
24065 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11355 {
11356 13185 memset(temp_sub,0,sizeof(subscreen_object));
11357
11358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13185 times.
13185 switch(g->objects[j].type)
11359 {
11360 case ssoTEXT:
11361 case ssoTEXTBOX:
11362 case ssoCURRENTITEMTEXT:
11363 case ssoCURRENTITEMCLASSTEXT:
11364 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11365
11366 //fall through
11367 default:
11368 13185 memset(&g->objects[j],0,sizeof(subscreen_object));
11369 13185 break;
11370 }
11371
11372
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->type),f))
11373 return qe_invalid;
11374
11375
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->pos),f))
11376 return qe_invalid;
11377
11378
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(s_version < 5)
11379 {
11380 switch(temp_sub->pos)
11381 {
11382 case 0:
11383 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11384 break;
11385
11386 case 1:
11387 temp_sub->pos = sspUP;
11388 break;
11389
11390 case 2:
11391 temp_sub->pos = sspDOWN;
11392 break;
11393
11394 default:
11395 temp_sub->pos = 0;
11396 }
11397 }
11398
11399
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->x),f))
11400 return qe_invalid;
11401
11402
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->y),f))
11403 return qe_invalid;
11404
11405
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->w),f))
11406 return qe_invalid;
11407
11408
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->h),f))
11409 return qe_invalid;
11410
11411
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->colortype1),f))
11412 return qe_invalid;
11413
11414
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->color1),f))
11415 return qe_invalid;
11416
11417
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->colortype2),f))
11418 return qe_invalid;
11419
11420
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->color2),f))
11421 return qe_invalid;
11422
11423
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->colortype3),f))
11424 return qe_invalid;
11425
11426
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->color3),f))
11427 return qe_invalid;
11428
11429
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d1),f))
11430 return qe_invalid;
11431
11432
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d2),f))
11433 return qe_invalid;
11434
11435
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d3),f))
11436 return qe_invalid;
11437
11438
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d4),f))
11439 return qe_invalid;
11440
11441
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d5),f))
11442 return qe_invalid;
11443
11444
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d6),f))
11445 return qe_invalid;
11446
11447
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d7),f))
11448 return qe_invalid;
11449
11450
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d8),f))
11451 return qe_invalid;
11452
11453
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d9),f))
11454 return qe_invalid;
11455
11456
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d10),f))
11457 return qe_invalid;
11458
11459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13185 times.
13185 if(s_version < 2)
11460 {
11461 if(!p_igetl(&(temp_sub->speed),f))
11462 return qe_invalid;
11463
11464 if(!p_igetl(&(temp_sub->delay),f))
11465 return qe_invalid;
11466
11467 if(!p_igetl(&(temp_sub->frame),f))
11468 return qe_invalid;
11469 }
11470 else
11471 {
11472
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->speed),f))
11473 return qe_invalid;
11474
11475
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->delay),f))
11476 return qe_invalid;
11477
11478
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->frame),f))
11479 return qe_invalid;
11480 }
11481
11482 13185 int32_t temp_size=0;
11483
11484 // bool deletets = false;
11485
4/4
✓ Branch 0 taken 5813 times.
✓ Branch 1 taken 1329 times.
✓ Branch 2 taken 5892 times.
✓ Branch 3 taken 151 times.
13185 switch(temp_sub->type)
11486 {
11487 case ssoTEXT:
11488 case ssoTEXTBOX:
11489 case ssoCURRENTITEMTEXT:
11490 case ssoCURRENTITEMCLASSTEXT:
11491 {
11492 word temptempsize;
11493
11494
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!p_igetw(&temptempsize,f))
11495 {
11496 return qe_invalid;
11497 }
11498
11499 //temptempsize = temp1 + (temp2 << 8);
11500 1329 temp_size = (int32_t)temptempsize;
11501 1329 uint32_t char_length = temp_size+2;
11502
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if (char_length > MAX_DP1_LEN)
11503 {
11504 return qe_invalid;
11505 }
11506 1329 tempdp1[char_length - 1] = '\0';
11507
11508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(temp_size)
11509
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!pfread(tempdp1,temp_size+1,f))
11510 return qe_invalid;
11511 1329 break;
11512 }
11513
11514 case ssoLIFEMETER:
11515
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11516 temp_sub->d3 = 1;
11517
11518
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11519 return qe_invalid;
11520
11521 151 break;
11522
11523
11524 case ssoCURRENTITEM:
11525
11526
1/2
✓ Branch 0 taken 5813 times.
✗ Branch 1 not taken.
5813 if(s_version < 6)
11527 {
11528 switch(temp_sub->d1)
11529 {
11530 case ssiBOMB:
11531 temp_sub->d1 = itype_bomb;
11532 break;
11533
11534 case ssiSWORD:
11535 temp_sub->d1 = itype_sword;
11536 break;
11537
11538 case ssiSHIELD:
11539 temp_sub->d1 = itype_shield;
11540 break;
11541
11542 case ssiCANDLE:
11543 temp_sub->d1 = itype_candle;
11544 break;
11545
11546 case ssiLETTER:
11547 temp_sub->d1 = itype_letter;
11548 break;
11549
11550 case ssiPOTION:
11551 temp_sub->d1 = itype_potion;
11552 break;
11553
11554 case ssiLETTERPOTION:
11555 temp_sub->d1 = itype_letterpotion;
11556 break;
11557
11558 case ssiBOW:
11559 temp_sub->d1 = itype_bow;
11560 break;
11561
11562 case ssiARROW:
11563 temp_sub->d1 = itype_arrow;
11564 break;
11565
11566 case ssiBOWANDARROW:
11567 temp_sub->d1 = itype_bowandarrow;
11568 break;
11569
11570 case ssiBAIT:
11571 temp_sub->d1 = itype_bait;
11572 break;
11573
11574 case ssiRING:
11575 temp_sub->d1 = itype_ring;
11576 break;
11577
11578 case ssiBRACELET:
11579 temp_sub->d1 = itype_bracelet;
11580 break;
11581
11582 case ssiMAP:
11583 temp_sub->d1 = itype_map;
11584 break;
11585
11586 case ssiCOMPASS:
11587 temp_sub->d1 = itype_compass;
11588 break;
11589
11590 case ssiBOSSKEY:
11591 temp_sub->d1 = itype_bosskey;
11592 break;
11593
11594 case ssiMAGICKEY:
11595 temp_sub->d1 = itype_magickey;
11596 break;
11597
11598 case ssiBRANG:
11599 temp_sub->d1 = itype_brang;
11600 break;
11601
11602 case ssiWAND:
11603 temp_sub->d1 = itype_wand;
11604 break;
11605
11606 case ssiRAFT:
11607 temp_sub->d1 = itype_raft;
11608 break;
11609
11610 case ssiLADDER:
11611 temp_sub->d1 = itype_ladder;
11612 break;
11613
11614 case ssiWHISTLE:
11615 temp_sub->d1 = itype_whistle;
11616 break;
11617
11618 case ssiBOOK:
11619 temp_sub->d1 = itype_book;
11620 break;
11621
11622 case ssiWALLET:
11623 temp_sub->d1 = itype_wallet;
11624 break;
11625
11626 case ssiSBOMB:
11627 temp_sub->d1 = itype_sbomb;
11628 break;
11629
11630 case ssiHCPIECE:
11631 temp_sub->d1 = itype_heartpiece;
11632 break;
11633
11634 case ssiAMULET:
11635 temp_sub->d1 = itype_amulet;
11636 break;
11637
11638 case ssiFLIPPERS:
11639 temp_sub->d1 = itype_flippers;
11640 break;
11641
11642 case ssiHOOKSHOT:
11643 temp_sub->d1 = itype_hookshot;
11644 break;
11645
11646 case ssiLENS:
11647 temp_sub->d1 = itype_lens;
11648 break;
11649
11650 case ssiHAMMER:
11651 temp_sub->d1 = itype_hammer;
11652 break;
11653
11654 case ssiBOOTS:
11655 temp_sub->d1 = itype_boots;
11656 break;
11657
11658 case ssiDIVINEFIRE:
11659 temp_sub->d1 = itype_divinefire;
11660 break;
11661
11662 case ssiDIVINEESCAPE:
11663 temp_sub->d1 = itype_divineescape;
11664 break;
11665
11666 case ssiDIVINEPROTECTION:
11667 temp_sub->d1 = itype_divineprotection;
11668 break;
11669
11670 case ssiQUIVER:
11671 temp_sub->d1 = itype_quiver;
11672 break;
11673
11674 case ssiBOMBBAG:
11675 temp_sub->d1 = itype_bombbag;
11676 break;
11677
11678 case ssiCBYRNA:
11679 temp_sub->d1 = itype_cbyrna;
11680 break;
11681
11682 case ssiROCS:
11683 temp_sub->d1 = itype_rocs;
11684 break;
11685
11686 case ssiHOVERBOOTS:
11687 temp_sub->d1 = itype_hoverboots;
11688 break;
11689
11690 case ssiSPINSCROLL:
11691 temp_sub->d1 = itype_spinscroll;
11692 break;
11693
11694 case ssiCROSSSCROLL:
11695 temp_sub->d1 = itype_crossscroll;
11696 break;
11697
11698 case ssiQUAKESCROLL:
11699 temp_sub->d1 = itype_quakescroll;
11700 break;
11701
11702 case ssiWHISPRING:
11703 temp_sub->d1 = itype_whispring;
11704 break;
11705
11706 case ssiCHARGERING:
11707 temp_sub->d1 = itype_chargering;
11708 break;
11709
11710 case ssiPERILSCROLL:
11711 temp_sub->d1 = itype_perilscroll;
11712 break;
11713
11714 case ssiWEALTHMEDAL:
11715 temp_sub->d1 = itype_wealthmedal;
11716 break;
11717
11718 case ssiHEARTRING:
11719 temp_sub->d1 = itype_heartring;
11720 break;
11721
11722 case ssiMAGICRING:
11723 temp_sub->d1 = itype_magicring;
11724 break;
11725
11726 case ssiSPINSCROLL2:
11727 temp_sub->d1 = itype_spinscroll2;
11728 break;
11729
11730 case ssiQUAKESCROLL2:
11731 temp_sub->d1 = itype_quakescroll2;
11732 break;
11733
11734 case ssiAGONY:
11735 temp_sub->d1 = itype_agony;
11736 break;
11737
11738 case ssiSTOMPBOOTS:
11739 temp_sub->d1 = itype_stompboots;
11740 break;
11741
11742 case ssiWHIMSICALRING:
11743 temp_sub->d1 = itype_whimsicalring;
11744 break;
11745
11746 case ssiPERILRING:
11747 temp_sub->d1 = itype_perilring;
11748 break;
11749
11750 default:
11751 temp_sub->d1 += itype_custom1 - ssiMAX;
11752 }
11753 }
11754
11755 //fall-through
11756 default:
11757
1/2
✓ Branch 0 taken 11705 times.
✗ Branch 1 not taken.
11705 if(!p_getc(&(temp_sub->dp1),f))
11758 return qe_invalid;
11759
11760 11705 break;
11761 }
11762
11763
2/2
✓ Branch 0 taken 4501 times.
✓ Branch 1 taken 8684 times.
13185 if(s_version < 7)
11764 {
11765
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11766 {
11767 case ssoMAGICGAUGE:
11768 {
11769
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11770 192 temp_sub->d9 = -1; //-1 now represents 'always'
11771 227 break;
11772 }
11773 case ssoLIFEGAUGE:
11774 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11775 432 break;
11776 }
11777 8684 }
11778
11779
3/3
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 11400 times.
✓ Branch 2 taken 456 times.
13185 switch(temp_sub->type)
11780 {
11781 case ssoTEXT:
11782 case ssoTEXTBOX:
11783 case ssoCURRENTITEMTEXT:
11784 case ssoCURRENTITEMCLASSTEXT:
11785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1329 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11786
11787 1329 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11788 1329 g->objects[j].dp1 = new char[temp_size+2];
11789 1329 strcpy((char*)g->objects[j].dp1,tempdp1);
11790 1329 break;
11791
11792 case ssoCOUNTER:
11793
1/2
✓ Branch 0 taken 456 times.
✗ Branch 1 not taken.
456 if(s_version<3)
11794 {
11795 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11796 temp_sub->d8=0;
11797 }
11798
11799 default:
11800 11856 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11801 11856 break;
11802 }
11803
11804 13185 g->name[0] = '\0';
11805 13185 strncat(g->name, tempname, 64 - 1);
11806 13185 g->ss_type = temp_ss;
11807 13185 }
11808
11809
2/2
✓ Branch 0 taken 2772095 times.
✓ Branch 1 taken 10880 times.
2782975 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11810 {
11811 //clear all unused object in this subscreen -DD
11812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2772095 times.
2772095 switch(g->objects[j].type)
11813 {
11814 case ssoTEXT:
11815 case ssoTEXTBOX:
11816 case ssoCURRENTITEMTEXT:
11817 case ssoCURRENTITEMCLASSTEXT:
11818 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11819
11820 //fall through
11821 default:
11822 2772095 memset(&g->objects[j],0,sizeof(subscreen_object));
11823 2772095 break;
11824 }
11825 2772095 }
11826
11827 10880 return 0;
11828 10880 }
11829
11830 114 int32_t readsubscreens(PACKFILE *f)
11831 {
11832 word s_version, s_cversion;
11833 dword dummy;
11834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
11835 return qe_invalid;
11836 114 FFCore.quest_format[vSubscreen] = s_version;
11837
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
11838 return qe_invalid;
11839
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy,f)) //section size
11840 return qe_invalid;
11841
11842
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if(s_version < 8)
11843 85 return read_old_subscreens(f,s_version);
11844
11845 29 subscreens_active.clear();
11846 29 subscreens_passive.clear();
11847 29 subscreens_overlay.clear();
11848
11849 byte sz;
11850
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&sz,f))
11851 return qe_invalid;
11852
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 29 times.
121 for(byte q = 0; q < sz; ++q)
11853 {
11854 92 ZCSubscreen& tmp = subscreens_active.emplace_back();
11855
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if (auto ret = tmp.read(f, s_version))
11856 return ret;
11857 92 }
11858
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&sz,f))
11859 return qe_invalid;
11860
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(byte q = 0; q < sz; ++q)
11861 {
11862 116 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11863
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (auto ret = tmp.read(f, s_version))
11864 return ret;
11865 116 }
11866
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&sz,f))
11867 return qe_invalid;
11868
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 29 times.
45 for(byte q = 0; q < sz; ++q)
11869 {
11870 16 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (auto ret = tmp.read(f, s_version))
11872 return ret;
11873 16 }
11874 29 return 0;
11875 114 }
11876
11877 void reset_subscreen(subscreen_group *tempss)
11878 {
11879 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11880 {
11881 switch(tempss->objects[i].type)
11882 {
11883 case ssoTEXT:
11884 case ssoTEXTBOX:
11885 case ssoCURRENTITEMTEXT:
11886 case ssoCURRENTITEMCLASSTEXT:
11887 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11888
11889 //fall through
11890 default:
11891 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11892 break;
11893 }
11894 }
11895 }
11896
11897 31 void reset_subscreens()
11898 {
11899 31 subscreens_active.clear();
11900 31 subscreens_passive.clear();
11901 31 subscreens_overlay.clear();
11902 31 }
11903
11904 31 int32_t setupsubscreens()
11905 {
11906 31 reset_subscreens();
11907 //return 0;
11908
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 62 times.
93 for(int q = 0; q < 2; ++q)
11909 {
11910 62 subscreens_active.emplace_back();
11911 62 subscreens_passive.emplace_back();
11912 62 }
11913 31 int32_t tempsubscreen=subscr_mode;
11914
11915
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11916 tempsubscreen=0;
11917
11918
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11919 {
11920 case ssdtOLD:
11921 case ssdtNEWSUBSCR:
11922 case ssdtREV2:
11923 case ssdtBSZELDA:
11924 case ssdtBSZELDAMODIFIED:
11925 case ssdtBSZELDAENHANCED:
11926 case ssdtBSZELDACOMPLETE:
11927 {
11928 31 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11929 31 subscreens_active[0].sub_type=sstACTIVE;
11930 31 subscreens_active[0].name = "Active Subscreen (Triforce)";
11931 31 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11932 31 subscreens_active[1].sub_type=sstACTIVE;
11933 31 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11934 31 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11935 31 subscreens_passive[0].sub_type=sstPASSIVE;
11936 31 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11937 31 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11938 31 subscreens_passive[1].sub_type=sstPASSIVE;
11939 31 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11940 31 break;
11941 }
11942
11943 case ssdtZ3:
11944 {
11945 subscreens_active[0].load_old(z3_active_a);
11946 subscreens_active[0].sub_type=sstACTIVE;
11947 subscreens_active[1].load_old(z3_active_ab);
11948 subscreens_active[1].sub_type=sstACTIVE;
11949 subscreens_passive[0].load_old(z3_passive_a);
11950 subscreens_passive[0].sub_type=sstPASSIVE;
11951 subscreens_passive[1].load_old(z3_passive_ab);
11952 subscreens_passive[1].sub_type=sstPASSIVE;
11953 break;
11954 }
11955 }
11956 31 subscr_mode = ssdtMAX;
11957 31 return 0;
11958 }
11959
11960 extern script_data *ffscripts[NUMSCRIPTFFC];
11961 extern script_data *itemscripts[NUMSCRIPTITEM];
11962 extern script_data *guyscripts[NUMSCRIPTGUYS];
11963 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11964 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11965 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11966 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11967 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11968 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11969 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11970 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11971 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11972 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11973
11974
11975
11976 100 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11977 {
11978 int32_t dummy;
11979 100 word s_version=0, s_cversion=0, zmeta_version=0;
11980 100 byte numscripts=0;
11981 100 numscripts=numscripts; //to avoid unused variables warnings
11982 int32_t ret;
11983
11984 //section version info
11985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&s_version,f))
11986 {
11987 return qe_invalid;
11988 }
11989
11990 100 FFCore.quest_format[vFFScript] = s_version;
11991
11992
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_cversion,f))
11993 {
11994 return qe_invalid;
11995 }
11996
11997
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 37 times.
100 if(s_version >= 18)
11998 {
11999
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetw(&zmeta_version,f))
12000 {
12001 return qe_invalid;
12002 }
12003 37 }
12004
12005 //al_trace("Scripts version %d\n", s_version);
12006 //section size
12007
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&dummy,f))
12008 {
12009 return qe_invalid;
12010 }
12011
12012 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12013 100 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12014 //miscQdata *the_misc;
12015
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 77 times.
100 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12016 100 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12017
12018 //finally... section data
12019
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 60 times.
58468 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12020 {
12021 58368 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12022
12023
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if (ret)
12024 {
12025 return qe_invalid;
12026 }
12027 58368 }
12028
12029 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12030 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12031 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12032 * there was a version bump a week before a change that broke stuff.
12033 */
12034
7/8
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 37 times.
✓ Branch 7 taken 37 times.
60 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12035 {
12036 97 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12037 97 }
12038
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(s_version < 19)
12039 {
12040 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12041 77 }
12042
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version > 1)
12044 {
12045
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12046 {
12047 29184 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12048
12049
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (ret)
12050 {
12051 return qe_invalid;
12052 }
12053 29184 }
12054
12055
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12056 {
12057 29184 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12058
12059
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (ret)
12060 {
12061 return qe_invalid;
12062 }
12063 29184 }
12064
12065
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 script_data *fake = new script_data(ScriptType::None, 0);
12066
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12067 {
12068 29184 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &fake, zmeta_version);
12069
12070
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (ret)
12071 {
12072 return qe_invalid;
12073 }
12074 29184 }
12075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 delete fake;
12076
12077
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12078 {
12079 29184 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12080
12081
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (ret)
12082 {
12083 return qe_invalid;
12084 }
12085 29184 }
12086
12087
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(s_version > 16)
12088 {
12089
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 37 times.
333 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12090 {
12091 296 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12092
12093
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if (ret)
12094 {
12095 return qe_invalid;
12096 }
12097 296 }
12098 37 }
12099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
12100 {
12101 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12102 {
12103 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12104
12105 if (ret)
12106 {
12107 return qe_invalid;
12108 }
12109 }
12110
12111 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12112 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12113
12114 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12115 }
12116
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12117 {
12118
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12119 {
12120 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12121
12122
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12123 {
12124 return qe_invalid;
12125 }
12126 308 }
12127
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12129
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12130
12131
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12132
12133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12134
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12135
12136
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12137
12138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12139
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12140
12141
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12142
12143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12144
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12145
12146
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12147 77 }
12148 else
12149 {
12150 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12151 {
12152 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12153
12154 if (ret)
12155 {
12156 return qe_invalid;
12157 }
12158 }
12159
12160 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12161 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12162
12163 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12164
12165 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12166 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12167
12168 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12169
12170 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12171 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12172
12173 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12174
12175 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12176 delete globalscripts[GLOBAL_SCRIPT_F6];
12177
12178 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12179
12180 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12181 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12182
12183 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12184 }
12185
12186
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(s_version > 10) //expanded the number of Player scripts to 5.
12187 {
12188
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 37 times.
222 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12189 {
12190 185 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12191
12192
1/2
✓ Branch 0 taken 185 times.
✗ Branch 1 not taken.
185 if (ret)
12193 {
12194 return qe_invalid;
12195 }
12196 185 }
12197 37 }
12198 else
12199 {
12200
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12201 {
12202 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12203
12204
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12205 {
12206 return qe_invalid;
12207 }
12208 231 }
12209
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12210
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12211
12212
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data(ScriptType::Player, 3);
12213
12214
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12216
12217
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data(ScriptType::Player, 4);
12218 }
12219
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
114 if(s_version > 8 && s_version < 10)
12220 {
12221
12222 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12223 {
12224 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12225
12226 if (ret)
12227 {
12228 return qe_invalid;
12229 }
12230 }
12231 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12232 {
12233 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12234
12235 if (ret)
12236 {
12237 return qe_invalid;
12238 }
12239 }
12240
12241 }
12242
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >= 10)
12243 {
12244
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12245 {
12246 9472 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12247
12248
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (ret)
12249 {
12250 return qe_invalid;
12251 }
12252 9472 }
12253
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12254 {
12255 9472 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12256
12257
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (ret)
12258 {
12259 return qe_invalid;
12260 }
12261 9472 }
12262
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12263 {
12264 9472 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12265
12266
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (ret)
12267 {
12268 return qe_invalid;
12269 }
12270 9472 }
12271
12272 37 }
12273
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >=12)
12274 {
12275
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 37 times.
9509 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12276 {
12277 9472 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12278
12279
1/2
✓ Branch 0 taken 9472 times.
✗ Branch 1 not taken.
9472 if (ret)
12280 {
12281 return qe_invalid;
12282 }
12283 9472 }
12284 37 }
12285
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >=15)
12286 {
12287
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 37 times.
18981 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12288 {
12289 18944 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12290
12291
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if (ret)
12292 {
12293 return qe_invalid;
12294 }
12295 18944 }
12296 37 }
12297
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >19)
12298 {
12299 37 word numgenscripts = NUMSCRIPTSGENERIC;
12300
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetw(&numgenscripts,f))
12301 {
12302 return qe_invalid;
12303 }
12304
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 37 times.
18981 for(int32_t i = 0; i < numgenscripts; i++)
12305 {
12306 18944 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12307
12308
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if (ret)
12309 {
12310 return qe_invalid;
12311 }
12312 18944 }
12313 37 }
12314
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if(s_version >21)
12315 {
12316 29 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12317
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&numsubscripts,f))
12318 {
12319 return qe_invalid;
12320 }
12321
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < numsubscripts; i++)
12322 {
12323 7424 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12324
12325
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if (ret)
12326 {
12327 return qe_invalid;
12328 }
12329 7424 }
12330 29 }
12331 114 }
12332
12333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version > 2)
12334 {
12335 int32_t bufsize;
12336 114 p_igetl(&bufsize, f);
12337
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if (bufsize < 0 || bufsize > 1024*1024*10)
12338 {
12339 // God help anyone storing more than 10MB of code in the script buffer.
12340 return qe_invalid;
12341 }
12342 114 char * buf = new char[bufsize+1];
12343 114 pfread(buf, bufsize, f);
12344 114 buf[bufsize]=0;
12345
12346
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 zScript = string(buf);
12347
12348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 delete[] buf;
12349 word numffcbindings;
12350 114 p_igetw(&numffcbindings, f);
12351
12352
2/2
✓ Branch 0 taken 1513 times.
✓ Branch 1 taken 114 times.
1627 for(int32_t i=0; i<numffcbindings; i++)
12353 {
12354 word id;
12355 1513 p_igetw(&id, f);
12356 1513 p_igetl(&bufsize, f);
12357
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if (bufsize < 0 || bufsize > 1024)
12358 return qe_invalid;
12359 1513 buf = new char[bufsize+1];
12360 1513 pfread(buf, bufsize, f);
12361 1513 buf[bufsize]=0;
12362
12363 //fix for buggy older saved quests -DD
12364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1513 times.
1513 if(id < NUMSCRIPTFFC-1)
12365 1513 ffcmap[id].scriptname = buf;
12366
12367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1513 times.
1513 delete[] buf;
12368 1513 }
12369
12370 word numglobalbindings;
12371 114 p_igetw(&numglobalbindings, f);
12372
12373
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 114 times.
550 for(int32_t i=0; i<numglobalbindings; i++)
12374 {
12375 word id;
12376 436 p_igetw(&id, f);
12377 436 p_igetl(&bufsize, f);
12378
2/4
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 436 times.
✗ Branch 3 not taken.
436 if (bufsize < 0 || bufsize > 1024)
12379 return qe_invalid;
12380 436 buf = new char[bufsize+1];
12381 436 pfread(buf, bufsize, f);
12382 436 buf[bufsize]=0;
12383
12384 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12385 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12386 // Ignore these. -DD
12387
3/4
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 277 times.
436 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12388 {
12389 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12390
1/2
✓ Branch 0 taken 277 times.
✗ Branch 1 not taken.
277 if(strcmp(buf,"~Continue") == 0)
12391 {
12392 globalmap[id].scriptname = "";
12393
12394 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12395 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12396 }
12397 else
12398 {
12399 277 globalmap[id].scriptname = buf;
12400 }
12401 277 }
12402
12403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 delete[] buf;
12404 436 }
12405
12406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version > 3)
12407 {
12408 word numitembindings;
12409 114 p_igetw(&numitembindings, f);
12410
12411
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 114 times.
206 for(int32_t i=0; i<numitembindings; i++)
12412 {
12413 word id;
12414 92 p_igetw(&id, f);
12415 92 p_igetl(&bufsize, f);
12416
2/4
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
92 if (bufsize < 0 || bufsize > 1024)
12417 return qe_invalid;
12418 92 buf = new char[bufsize+1];
12419 92 pfread(buf, bufsize, f);
12420 92 buf[bufsize]=0;
12421
12422 //fix this too
12423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(id <NUMSCRIPTITEM-1)
12424 92 itemmap[id].scriptname = buf;
12425
12426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 delete[] buf;
12427 92 }
12428 114 }
12429 //(v9+)
12430
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version > 8)
12431 {
12432 //npc scripts
12433 word numnpcbindings;
12434 37 p_igetw(&numnpcbindings, f);
12435
12436
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 37 times.
41 for(int32_t i=0; i<numnpcbindings; i++)
12437 {
12438 word id;
12439 4 p_igetw(&id, f);
12440 4 p_igetl(&bufsize, f);
12441
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if (bufsize < 0 || bufsize > 1024)
12442 return qe_invalid;
12443 4 buf = new char[bufsize+1];
12444 4 pfread(buf, bufsize, f);
12445 4 buf[bufsize]=0;
12446
12447 //fix this too
12448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(id <NUMSCRIPTGUYS-1)
12449 4 npcmap[id].scriptname = buf;
12450
12451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 delete[] buf;
12452 4 }
12453 //lweapon
12454 word numlwpnbindings;
12455 37 p_igetw(&numlwpnbindings, f);
12456
12457
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 37 times.
70 for(int32_t i=0; i<numlwpnbindings; i++)
12458 {
12459 word id;
12460 33 p_igetw(&id, f);
12461 33 p_igetl(&bufsize, f);
12462
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
33 if (bufsize < 0 || bufsize > 1024)
12463 return qe_invalid;
12464 33 buf = new char[bufsize+1];
12465 33 pfread(buf, bufsize, f);
12466 33 buf[bufsize]=0;
12467
12468 //fix this too
12469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(id <NUMSCRIPTWEAPONS-1)
12470 33 lwpnmap[id].scriptname = buf;
12471
12472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 delete[] buf;
12473 33 }
12474 //eweapon
12475 word numewpnbindings;
12476 37 p_igetw(&numewpnbindings, f);
12477
12478
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 37 times.
92 for(int32_t i=0; i<numewpnbindings; i++)
12479 {
12480 word id;
12481 55 p_igetw(&id, f);
12482 55 p_igetl(&bufsize, f);
12483
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 if (bufsize < 0 || bufsize > 1024)
12484 return qe_invalid;
12485 55 buf = new char[bufsize+1];
12486 55 pfread(buf, bufsize, f);
12487 55 buf[bufsize]=0;
12488
12489 //fix this too
12490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(id <NUMSCRIPTWEAPONS-1)
12491 55 ewpnmap[id].scriptname = buf;
12492
12493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 delete[] buf;
12494 55 }
12495 //hero
12496 word numherobindings;
12497 37 p_igetw(&numherobindings, f);
12498
12499
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 37 times.
39 for(int32_t i=0; i<numherobindings; i++)
12500 {
12501 word id;
12502 2 p_igetw(&id, f);
12503 2 p_igetl(&bufsize, f);
12504
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if (bufsize < 0 || bufsize > 1024)
12505 return qe_invalid;
12506 2 buf = new char[bufsize+1];
12507 2 pfread(buf, bufsize, f);
12508 2 buf[bufsize]=0;
12509
12510 //fix this too
12511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(id <NUMSCRIPTPLAYER-1)
12512 2 playermap[id].scriptname = buf;
12513
12514
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 delete[] buf;
12515 2 }
12516 //dmaps
12517 word numdmapbindings;
12518 37 p_igetw(&numdmapbindings, f);
12519
12520
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 37 times.
67 for(int32_t i=0; i<numdmapbindings; i++)
12521 {
12522 word id;
12523 30 p_igetw(&id, f);
12524 30 p_igetl(&bufsize, f);
12525
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if (bufsize < 0 || bufsize > 1024)
12526 return qe_invalid;
12527 30 buf = new char[bufsize+1];
12528 30 pfread(buf, bufsize, f);
12529 30 buf[bufsize]=0;
12530
12531 //fix this too
12532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(id <NUMSCRIPTSDMAP-1)
12533 30 dmapmap[id].scriptname = buf;
12534
12535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 delete[] buf;
12536 30 }
12537 //screen
12538 word numscreenbindings;
12539 37 p_igetw(&numscreenbindings, f);
12540
12541
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 37 times.
74 for(int32_t i=0; i<numscreenbindings; i++)
12542 {
12543 word id;
12544 37 p_igetw(&id, f);
12545 37 p_igetl(&bufsize, f);
12546
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if (bufsize < 0 || bufsize > 1024)
12547 return qe_invalid;
12548 37 buf = new char[bufsize+1];
12549 37 pfread(buf, bufsize, f);
12550 37 buf[bufsize]=0;
12551
12552 //fix this too
12553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(id <NUMSCRIPTSDMAP-1)
12554 37 screenmap[id].scriptname = buf;
12555
12556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 delete[] buf;
12557 37 }
12558 37 }
12559
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version > 11)
12560 {
12561 word numspritebindings;
12562 37 p_igetw(&numspritebindings, f);
12563
12564
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 37 times.
46 for(int32_t i=0; i<numspritebindings; i++)
12565 {
12566 word id;
12567 9 p_igetw(&id, f);
12568 9 p_igetl(&bufsize, f);
12569
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if (bufsize < 0 || bufsize > 1024)
12570 return qe_invalid;
12571 9 buf = new char[bufsize+1];
12572 9 pfread(buf, bufsize, f);
12573 9 buf[bufsize]=0;
12574
12575 //fix this too
12576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(id <NUMSCRIPTSDMAP-1)
12577 9 itemspritemap[id].scriptname = buf;
12578
12579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 delete[] buf;
12580 9 }
12581 37 }
12582
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version >= 15)
12583 {
12584 word numcombobindings;
12585 37 p_igetw(&numcombobindings, f);
12586
12587
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 37 times.
60 for(int32_t i=0; i<numcombobindings; i++)
12588 {
12589 word id;
12590 23 p_igetw(&id, f);
12591 23 p_igetl(&bufsize, f);
12592
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
12593 return qe_invalid;
12594 23 buf = new char[bufsize+1];
12595 23 pfread(buf, bufsize, f);
12596 23 buf[bufsize]=0;
12597
12598 //fix this too
12599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12600 23 comboscriptmap[id].scriptname = buf;
12601
12602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 delete[] buf;
12603 23 }
12604 37 }
12605
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 37 times.
114 if(s_version > 19)
12606 {
12607 word numgenericbindings;
12608 37 p_igetw(&numgenericbindings, f);
12609
12610
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
49 for(int32_t i=0; i<numgenericbindings; i++)
12611 {
12612 word id;
12613 12 p_igetw(&id, f);
12614 12 p_igetl(&bufsize, f);
12615
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (bufsize < 0 || bufsize > 1024)
12616 return qe_invalid;
12617 12 buf = new char[bufsize+1];
12618 12 pfread(buf, bufsize, f);
12619 12 buf[bufsize]=0;
12620
12621 //fix this too
12622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTSGENERIC-1)
12623 12 genericmap[id].scriptname = buf;
12624
12625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12626 12 }
12627 37 }
12628
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if(s_version > 21)
12629 {
12630 word numsubscreenbindings;
12631 29 p_igetw(&numsubscreenbindings, f);
12632
12633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 for(int32_t i=0; i<numsubscreenbindings; i++)
12634 {
12635 word id;
12636 p_igetw(&id, f);
12637 p_igetl(&bufsize, f);
12638 if (bufsize < 0 || bufsize > 1024)
12639 return qe_invalid;
12640 buf = new char[bufsize+1];
12641 pfread(buf, bufsize, f);
12642 buf[bufsize]=0;
12643
12644 //fix this too
12645 if(id <NUMSCRIPTSSUBSCREEN-1)
12646 subscreenmap[id].scriptname = buf;
12647
12648 delete[] buf;
12649 }
12650 29 }
12651 114 }
12652
12653 114 return 0;
12654 114 }
12655
12656 130 void reset_scripts()
12657 {
12658 #ifdef IS_PLAYER
12659 // We can't modify the script data while jit threads are possibly compiling them.
12660 void jit_shutdown();
12661 130 jit_shutdown();
12662 #endif
12663
12664
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12665 {
12666
1/2
✓ Branch 0 taken 66560 times.
✗ Branch 1 not taken.
66560 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12667 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12668 66560 }
12669
12670
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12671 {
12672
1/2
✓ Branch 0 taken 66560 times.
✗ Branch 1 not taken.
66560 if (ffscripts[i])
12673 66560 ffscripts[i]->disable();
12674 else
12675 ffscripts[i] = new script_data(ScriptType::FFC, i);
12676 66560 }
12677
12678
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12679 {
12680
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if (itemscripts[i])
12681 33280 itemscripts[i]->disable();
12682 else
12683 itemscripts[i] = new script_data(ScriptType::Item, i);
12684 33280 }
12685
12686
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12687 {
12688
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if (guyscripts[i])
12689 33280 guyscripts[i]->disable();
12690 else
12691 guyscripts[i] = new script_data(ScriptType::NPC, i);
12692 33280 }
12693
12694
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12695 {
12696
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if (screenscripts[i])
12697 33280 screenscripts[i]->disable();
12698 else
12699 screenscripts[i] = new script_data(ScriptType::Screen, i);
12700 33280 }
12701
12702
2/2
✓ Branch 0 taken 1040 times.
✓ Branch 1 taken 130 times.
1170 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12703 {
12704
1/2
✓ Branch 0 taken 1040 times.
✗ Branch 1 not taken.
1040 if (globalscripts[i])
12705 1040 globalscripts[i]->disable();
12706 else
12707 globalscripts[i] = new script_data(ScriptType::Global, i);
12708 1040 }
12709
12710
2/2
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 130 times.
780 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12711 {
12712
1/2
✓ Branch 0 taken 650 times.
✗ Branch 1 not taken.
650 if (playerscripts[i])
12713 650 playerscripts[i]->disable();
12714 else
12715 playerscripts[i] = new script_data(ScriptType::Player, i);
12716 650 }
12717
12718
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12719 {
12720
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if (lwpnscripts[i])
12721 33280 lwpnscripts[i]->disable();
12722 else
12723 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12724 33280 }
12725
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12726 {
12727
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if (ewpnscripts[i])
12728 33280 ewpnscripts[i]->disable();
12729 else
12730 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12731 33280 }
12732
12733
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12734 {
12735
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if (dmapscripts[i])
12736 33280 dmapscripts[i]->disable();
12737 else
12738 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12739 33280 }
12740
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12741 {
12742
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if (itemspritescripts[i])
12743 33280 itemspritescripts[i]->disable();
12744 else
12745 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12746 33280 }
12747
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 130 times.
66690 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12748 {
12749
1/2
✓ Branch 0 taken 66560 times.
✗ Branch 1 not taken.
66560 if (comboscripts[i])
12750 66560 comboscripts[i]->disable();
12751 else
12752 comboscripts[i] = new script_data(ScriptType::Combo, i);
12753 66560 }
12754
2/2
✓ Branch 0 taken 33280 times.
✓ Branch 1 taken 130 times.
33410 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12755 {
12756
1/2
✓ Branch 0 taken 33280 times.
✗ Branch 1 not taken.
33280 if (subscreenscripts[i])
12757 33280 subscreenscripts[i]->disable();
12758 else
12759 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12760 33280 }
12761 130 }
12762
12763 extern script_command command_list[];
12764 259324 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12765 {
12766 // TODO: refactor to just take a script_data*
12767
1/2
✓ Branch 0 taken 259324 times.
✗ Branch 1 not taken.
259324 ASSERT(*script);
12768
12769 //Please also update loadquest() when modifying this method -DD
12770 259324 char b33[34] = {0};
12771 259324 b33[33] = 0;
12772 259324 ffscript temp_script;
12773 259324 int32_t num_commands=1000;
12774
12775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259324 times.
259324 if(s_version>=2)
12776 {
12777
2/4
✓ Branch 0 taken 259324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259324 times.
✗ Branch 3 not taken.
259324 if(!p_igetl(&num_commands,f))
12778 {
12779 return qe_invalid;
12780 }
12781 259324 }
12782
12783 #ifdef ZC_FUZZ
12784 const int32_t command_limit = 300000;
12785 #else
12786 259324 const int32_t command_limit = 10000000;
12787 #endif
12788
2/4
✓ Branch 0 taken 259324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259324 times.
✗ Branch 3 not taken.
259324 if (num_commands < 0 || num_commands > command_limit)
12789 {
12790 return qe_invalid;
12791 }
12792
12793
1/2
✓ Branch 0 taken 259324 times.
✗ Branch 1 not taken.
259324 (*script)->null_script(num_commands);
12794
12795
2/2
✓ Branch 0 taken 140513 times.
✓ Branch 1 taken 118811 times.
259324 if(s_version >= 16)
12796 {
12797
1/2
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
140513 zasm_meta temp_meta;
12798
12799
2/4
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140513 times.
✗ Branch 3 not taken.
140513 if(!p_igetw(&(temp_meta.zasm_v),f))
12800 {
12801 return qe_invalid;
12802 }
12803
12804
2/4
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140513 times.
✗ Branch 3 not taken.
140513 if(!p_igetw(&(temp_meta.meta_v),f))
12805 {
12806 return qe_invalid;
12807 }
12808
12809
2/4
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140513 times.
✗ Branch 3 not taken.
140513 if(!p_igetw(&(temp_meta.ffscript_v),f))
12810 {
12811 return qe_invalid;
12812 }
12813
12814
2/4
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140513 times.
✗ Branch 3 not taken.
140513 if(!p_getc(&(temp_meta.script_type),f))
12815 {
12816 return qe_invalid;
12817 }
12818
12819
2/2
✓ Branch 0 taken 1124104 times.
✓ Branch 1 taken 140513 times.
1264617 for(int32_t q = 0; q < 8; ++q)
12820 {
12821
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1066552 times.
1124104 if(zmeta_version < 3)
12822 {
12823
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
12824 {
12825
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
12826 {
12827 return qe_invalid;
12828 }
12829 1899216 }
12830
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
12831 57552 }
12832 else
12833 {
12834
2/4
✓ Branch 0 taken 1066552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1066552 times.
✗ Branch 3 not taken.
1066552 if(!p_getcstr(&temp_meta.run_idens[q],f))
12835 {
12836 return qe_invalid;
12837 }
12838 }
12839 1124104 }
12840
12841
2/2
✓ Branch 0 taken 140513 times.
✓ Branch 1 taken 1124104 times.
1264617 for(int32_t q = 0; q < 8; ++q)
12842 {
12843
2/4
✓ Branch 0 taken 1124104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1124104 times.
✗ Branch 3 not taken.
1124104 if(!p_getc(&(temp_meta.run_types[q]),f))
12844 {
12845 return qe_invalid;
12846 }
12847 1124104 }
12848
12849
2/4
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140513 times.
✗ Branch 3 not taken.
140513 if(!p_getc(&(temp_meta.flags),f))
12850 {
12851 return qe_invalid;
12852 }
12853
12854
2/4
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140513 times.
✗ Branch 3 not taken.
140513 if(!p_igetw(&(temp_meta.compiler_v1),f))
12855 {
12856 return qe_invalid;
12857 }
12858
12859
2/4
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140513 times.
✗ Branch 3 not taken.
140513 if(!p_igetw(&(temp_meta.compiler_v2),f))
12860 {
12861 return qe_invalid;
12862 }
12863
12864
2/4
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140513 times.
✗ Branch 3 not taken.
140513 if(!p_igetw(&(temp_meta.compiler_v3),f))
12865 {
12866 return qe_invalid;
12867 }
12868
12869
2/4
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140513 times.
✗ Branch 3 not taken.
140513 if(!p_igetw(&(temp_meta.compiler_v4),f))
12870 {
12871 return qe_invalid;
12872 }
12873
12874
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 133319 times.
140513 if(zmeta_version == 2)
12875 {
12876
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12877 {
12878
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12879 {
12880 return qe_invalid;
12881 }
12882 237402 }
12883
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
12884
12885
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12886 {
12887
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12888 {
12889 return qe_invalid;
12890 }
12891 237402 }
12892
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
12893 7194 }
12894
1/2
✓ Branch 0 taken 133319 times.
✗ Branch 1 not taken.
133319 else if(zmeta_version > 2)
12895 {
12896
2/4
✓ Branch 0 taken 133319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133319 times.
✗ Branch 3 not taken.
133319 if(!p_getcstr(&temp_meta.script_name,f))
12897 return qe_invalid;
12898
2/4
✓ Branch 0 taken 133319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133319 times.
✗ Branch 3 not taken.
133319 if(!p_getcstr(&temp_meta.author,f))
12899 return qe_invalid;
12900 133319 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12901
2/2
✓ Branch 0 taken 1333190 times.
✓ Branch 1 taken 133319 times.
1466509 for(auto q = 0; q < num_meta_attrib; ++q)
12902 {
12903
2/4
✓ Branch 0 taken 1333190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1333190 times.
✗ Branch 3 not taken.
1333190 if(!p_getcstr(&temp_meta.attributes[q],f))
12904 return qe_invalid;
12905
2/4
✓ Branch 0 taken 1333190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1333190 times.
✗ Branch 3 not taken.
1333190 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12906 return qe_invalid;
12907 1333190 }
12908
2/2
✓ Branch 0 taken 1066552 times.
✓ Branch 1 taken 133319 times.
1199871 for(auto q = 0; q < 8; ++q)
12909 {
12910
2/4
✓ Branch 0 taken 1066552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1066552 times.
✗ Branch 3 not taken.
1066552 if(!p_getcstr(&temp_meta.attribytes[q],f))
12911 return qe_invalid;
12912
2/4
✓ Branch 0 taken 1066552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1066552 times.
✗ Branch 3 not taken.
1066552 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12913 return qe_invalid;
12914 1066552 }
12915
2/2
✓ Branch 0 taken 1066552 times.
✓ Branch 1 taken 133319 times.
1199871 for(auto q = 0; q < 8; ++q)
12916 {
12917
2/4
✓ Branch 0 taken 1066552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1066552 times.
✗ Branch 3 not taken.
1066552 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12918 return qe_invalid;
12919
2/4
✓ Branch 0 taken 1066552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1066552 times.
✗ Branch 3 not taken.
1066552 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12920 return qe_invalid;
12921 1066552 }
12922
2/2
✓ Branch 0 taken 2133104 times.
✓ Branch 1 taken 133319 times.
2266423 for(auto q = 0; q < 16; ++q)
12923 {
12924
2/4
✓ Branch 0 taken 2133104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2133104 times.
✗ Branch 3 not taken.
2133104 if(!p_getcstr(&temp_meta.usrflags[q],f))
12925 return qe_invalid;
12926
2/4
✓ Branch 0 taken 2133104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2133104 times.
✗ Branch 3 not taken.
2133104 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12927 return qe_invalid;
12928 2133104 }
12929 133319 }
12930
2/2
✓ Branch 0 taken 133319 times.
✓ Branch 1 taken 7194 times.
140513 if(zmeta_version > 3)
12931 {
12932
2/2
✓ Branch 0 taken 1066552 times.
✓ Branch 1 taken 133319 times.
1199871 for(auto q = 0; q < 8; ++q)
12933 {
12934
2/4
✓ Branch 0 taken 1066552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1066552 times.
✗ Branch 3 not taken.
1066552 if(!p_getcstr(&temp_meta.initd[q],f))
12935 return qe_invalid;
12936
2/4
✓ Branch 0 taken 1066552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1066552 times.
✗ Branch 3 not taken.
1066552 if(!p_getwstr(&temp_meta.initd_help[q],f))
12937 return qe_invalid;
12938 1066552 }
12939
2/2
✓ Branch 0 taken 1066552 times.
✓ Branch 1 taken 133319 times.
1199871 for(auto q = 0; q < 8; ++q)
12940 {
12941
2/4
✓ Branch 0 taken 1066552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1066552 times.
✗ Branch 3 not taken.
1066552 if(!p_getc(&temp_meta.initd_type[q],f))
12942 return qe_invalid;
12943 1066552 }
12944 133319 }
12945 else
12946 {
12947
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
12948 {
12949
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
12950 57552 }
12951 }
12952
12953
1/2
✓ Branch 0 taken 140513 times.
✗ Branch 1 not taken.
140513 (*script)->meta = temp_meta;
12954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140513 times.
140513 }
12955
12956
1/2
✓ Branch 0 taken 259324 times.
✗ Branch 1 not taken.
259324 temp_script.clear();
12957
1/2
✓ Branch 0 taken 21687750 times.
✗ Branch 1 not taken.
21687750 for(int32_t j=0; j<num_commands; j++)
12958 {
12959
2/4
✓ Branch 0 taken 21687750 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21687750 times.
✗ Branch 3 not taken.
21687750 if(!p_igetw(&(temp_script.command),f))
12960 {
12961 return qe_invalid;
12962 }
12963
12964
2/2
✓ Branch 0 taken 259324 times.
✓ Branch 1 taken 21428426 times.
21687750 if(temp_script.command == 0xFFFF)
12965 {
12966
1/2
✓ Branch 0 taken 259324 times.
✗ Branch 1 not taken.
259324 (*script)->zasm[j].clear();
12967 259324 break;
12968 }
12969 else
12970 {
12971
2/4
✓ Branch 0 taken 21428426 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21428426 times.
✗ Branch 3 not taken.
21428426 if(!p_igetl(&(temp_script.arg1),f))
12972 {
12973 return qe_invalid;
12974 }
12975
12976
2/4
✓ Branch 0 taken 21428426 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21428426 times.
✗ Branch 3 not taken.
21428426 if(!p_igetl(&(temp_script.arg2),f))
12977 {
12978 return qe_invalid;
12979 }
12980
12981
2/2
✓ Branch 0 taken 755805 times.
✓ Branch 1 taken 20672621 times.
21428426 if(s_version >= 21)
12982 {
12983 755805 uint32_t sz = 0;
12984
2/4
✓ Branch 0 taken 755805 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755805 times.
✗ Branch 3 not taken.
755805 if(!p_igetl(&sz,f))
12985 {
12986 return qe_invalid;
12987 }
12988
2/2
✓ Branch 0 taken 3141 times.
✓ Branch 1 taken 752664 times.
755805 if(sz) //string found
12989 {
12990
1/2
✓ Branch 0 taken 3141 times.
✗ Branch 1 not taken.
3141 temp_script.strptr = new std::string();
12991 char dummy;
12992
2/2
✓ Branch 0 taken 230419 times.
✓ Branch 1 taken 3141 times.
233560 for(size_t q = 0; q < sz; ++q)
12993 {
12994
2/4
✓ Branch 0 taken 230419 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230419 times.
✗ Branch 3 not taken.
230419 if(!p_getc(&dummy,f))
12995 {
12996 return qe_invalid;
12997 }
12998
1/2
✓ Branch 0 taken 230419 times.
✗ Branch 1 not taken.
230419 temp_script.strptr->push_back(dummy);
12999 230419 }
13000 3141 }
13001
2/4
✓ Branch 0 taken 755805 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755805 times.
✗ Branch 3 not taken.
755805 if(!p_igetl(&sz,f))
13002 {
13003 return qe_invalid;
13004 }
13005
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 755783 times.
755805 if(sz) //vector found
13006 {
13007
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 temp_script.vecptr = new std::vector<int32_t>();
13008 int32_t dummy;
13009
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 22 times.
374 for(size_t q = 0; q < sz; ++q)
13010 {
13011
2/4
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 352 times.
✗ Branch 3 not taken.
352 if(!p_igetl(&dummy,f))
13012 {
13013 return qe_invalid;
13014 }
13015
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 temp_script.vecptr->push_back(dummy);
13016 352 }
13017 22 }
13018 755805 }
13019
13020
1/2
✓ Branch 0 taken 21428426 times.
✗ Branch 1 not taken.
21428426 temp_script.give((*script)->zasm[j]);
13021 }
13022
1/2
✓ Branch 0 taken 21428426 times.
✗ Branch 1 not taken.
21428426 temp_script.clear();
13023 21428426 }
13024
13025
1/2
✓ Branch 0 taken 259324 times.
✗ Branch 1 not taken.
259324 (*script)->recalc_size();
13026
13027 259324 return 0;
13028 259324 }
13029
13030 extern SAMPLE customsfxdata[WAV_COUNT];
13031 extern uint8_t customsfxflag[WAV_COUNT>>3];
13032 extern int32_t sfxdat;
13033 extern DATAFILE *sfxdata;
13034 const char *old_sfx_string[Z35] =
13035 {
13036 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13037 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13038 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13039 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13040 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13041 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13042 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13043 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13044 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13045 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13046 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13047 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13048 };
13049 char *sfx_string[WAV_COUNT];
13050
13051 114 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13052 {
13053 //these are here to bypass compiler warnings about unused arguments
13054 114 Header=Header;
13055
13056 int32_t dummy;
13057 114 word s_version=0, s_cversion=0;
13058 //int32_t ret;
13059 114 SAMPLE temp_sample = {};
13060 114 temp_sample.loop_start=0;
13061 114 temp_sample.loop_end=0;
13062 114 temp_sample.param=0;
13063
13064 //section version info
13065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&s_version,f))
13066 {
13067 return qe_invalid;
13068 }
13069
13070 114 FFCore.quest_format[vSFX] = s_version;
13071
13072 //al_trace("SFX version %d\n", s_version);
13073
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
13074 {
13075 return qe_invalid;
13076 }
13077
13078 //section size
13079
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy,f))
13080 {
13081 return qe_invalid;
13082 }
13083
13084 /* HIGHLY UNORTHODOX UPDATING THING, by L
13085 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13086 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13087 * changing from 1 to 2.
13088 */
13089
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version < 2)
13090 set_qr(qr_GOTOLESSNOTEQUAL,1);
13091
13092 /* End highly unorthodox updating thing */
13093
13094 114 int32_t wavcount = WAV_COUNT;
13095
13096
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version < 6)
13097 wavcount = 128;
13098
13099 uint8_t tempflag[WAV_COUNT>>3];
13100
13101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(s_version < 4)
13102 {
13103 memset(tempflag, 0xFF, WAV_COUNT>>3);
13104 }
13105 else
13106 {
13107
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version < 6)
13108 memset(tempflag, 0, WAV_COUNT>>3);
13109
13110
2/2
✓ Branch 0 taken 3648 times.
✓ Branch 1 taken 114 times.
3762 for(int32_t i=0; i<(wavcount>>3); i++)
13111 {
13112 3648 p_getc(&tempflag[i], f);
13113 3648 }
13114
13115 }
13116
13117
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(s_version>4)
13118 {
13119
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=1; i<WAV_COUNT; i++)
13120 {
13121 29070 sprintf(sfx_string[i],"s%03d",i);
13122
13123
2/2
✓ Branch 0 taken 22230 times.
✓ Branch 1 taken 6840 times.
29070 if((i<Z35))
13124 6840 strcpy(sfx_string[i], old_sfx_string[i-1]);
13125
13126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29070 times.
29070 if(i>=wavcount)
13127 continue;
13128
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 26004 times.
29070 if(get_bit(tempflag, i-1))
13129 {
13130 char tempname[36];
13131
13132
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(!pfread(tempname, 36, f))
13133 {
13134 return qe_invalid;
13135 }
13136
13137 3066 sfx_string[i][0] = '\0';
13138 3066 strncat(sfx_string[i], tempname, 36 - 1);
13139 3066 }
13140 else
13141 {
13142 26004 sprintf(sfx_string[i],"s%03d",i);
13143
13144
2/2
✓ Branch 0 taken 21426 times.
✓ Branch 1 taken 4578 times.
26004 if(i<Z35)
13145 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13146 26004 sfx_string[i][35] = 0; //Force NULL Termination
13147 }
13148 29070 }
13149 114 }
13150 else
13151 {
13152 for(int32_t i=1; i<WAV_COUNT; i++)
13153 {
13154 sprintf(sfx_string[i],"s%03d",i);
13155
13156 if(i<Z35)
13157 strcpy(sfx_string[i], old_sfx_string[i-1]);
13158 }
13159 }
13160
13161 //finally... section data
13162
2/2
✓ Branch 0 taken 29070 times.
✓ Branch 1 taken 114 times.
29184 for(int32_t i=1; i<wavcount; i++)
13163 {
13164
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 26004 times.
29070 if(get_bit(tempflag, i-1))
13165 {
13166
13167
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(!p_igetl(&dummy,f))
13168 {
13169 return qe_invalid;
13170 }
13171
13172 3066 (temp_sample.bits) = dummy;
13173
13174
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(!p_igetl(&dummy,f))
13175 {
13176 return qe_invalid;
13177 }
13178
13179 3066 (temp_sample.stereo) = dummy;
13180
13181
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(!p_igetl(&dummy,f))
13182 {
13183 return qe_invalid;
13184 }
13185
13186 3066 (temp_sample.freq) = dummy;
13187
13188
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(!p_igetl(&dummy,f))
13189 {
13190 return qe_invalid;
13191 }
13192
13193 3066 (temp_sample.priority) = dummy;
13194
13195
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(!p_igetl(&(temp_sample.len),f))
13196 {
13197 return qe_invalid;
13198 }
13199
13200
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(!p_igetl(&(temp_sample.loop_start),f))
13201 {
13202 return qe_invalid;
13203 }
13204
13205
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(!p_igetl(&(temp_sample.loop_end),f))
13206 {
13207 return qe_invalid;
13208 }
13209
13210
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(!p_igetl(&(temp_sample.param),f))
13211 {
13212 return qe_invalid;
13213 }
13214
13215 // al_trace("F%i: L%i\n",i,temp_sample.len);
13216 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13217 3066 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13218
2/4
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3066 times.
3066 if (len < 0 || len > 10000000)
13219 {
13220 return qe_invalid;
13221 }
13222 3066 temp_sample.data = calloc(len,1);
13223
13224
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(s_version < 3)
13225 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13226
13227 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3066 times.
3066 if(s_version < 2)
13229 {
13230 if(!pfread(temp_sample.data, len,f))
13231 {
13232 return qe_invalid;
13233 }
13234 }
13235 else
13236 {
13237 //re-endianfy the data
13238 3066 int32_t wordstoread = len / sizeof(word);
13239
13240
2/2
✓ Branch 0 taken 86810701 times.
✓ Branch 1 taken 3066 times.
86813767 for(int32_t j=0; j<wordstoread; j++)
13241 {
13242 word temp;
13243
13244
1/2
✓ Branch 0 taken 86810701 times.
✗ Branch 1 not taken.
86810701 if(!p_igetw(&temp, f))
13245 {
13246 return qe_invalid;
13247 }
13248
13249 86810701 ((word *)temp_sample.data)[j] = temp;
13250 86810701 }
13251 }
13252 3066 }
13253
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 21426 times.
26004 else if(i < Z35)
13254 {
13255 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13256 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13257 4578 set_bit(tempflag, i-1, 1);
13258 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13259 4578 temp_sample.data = calloc(len,1);
13260 4578 memcpy(temp_sample.data, datsamp->data, len);
13261 4578 }
13262 21426 else continue;
13263
13264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7644 times.
7644 if(customsfxdata[i].data!=NULL)
13265 {
13266 // delete [] customsfxdata[i].data;
13267 7644 free(customsfxdata[i].data);
13268 7644 }
13269
13270 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13271 7644 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13272 7644 customsfxdata[i].data = calloc(len2,1);
13273 7644 customsfxdata[i].bits = temp_sample.bits;
13274 7644 customsfxdata[i].stereo = temp_sample.stereo;
13275 7644 customsfxdata[i].freq = temp_sample.freq;
13276 7644 customsfxdata[i].priority = temp_sample.priority;
13277 7644 customsfxdata[i].len = temp_sample.len;
13278 7644 customsfxdata[i].loop_start = temp_sample.loop_start;
13279 7644 customsfxdata[i].loop_end = temp_sample.loop_end;
13280 7644 customsfxdata[i].param = temp_sample.param;
13281 7644 int32_t cpylen = len2;
13282
13283
1/2
✓ Branch 0 taken 7644 times.
✗ Branch 1 not taken.
7644 if(s_version<3)
13284 {
13285 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13286 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13287 }
13288
13289 7644 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13290
13291 7644 free(temp_sample.data);
13292 7644 }
13293
13294 114 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13295
13296 114 sfxdat=0;
13297 114 return 0;
13298 114 }
13299
13300 130 void setupsfx()
13301 {
13302
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=1; i<WAV_COUNT; i++)
13303 {
13304 33150 sprintf(sfx_string[i],"s%03d",i);
13305
13306
2/2
✓ Branch 0 taken 25350 times.
✓ Branch 1 taken 7800 times.
33150 if(i<Z35)
13307 {
13308 7800 strcpy(sfx_string[i], old_sfx_string[i-1]);
13309 7800 }
13310
13311 33150 memset(customsfxflag, 0, WAV_COUNT>>3);
13312
13313 33150 int32_t j=i;
13314
13315
2/2
✓ Branch 0 taken 7930 times.
✓ Branch 1 taken 25220 times.
33150 if(i>Z35)
13316 {
13317 25220 i=Z35;
13318 25220 }
13319
13320 33150 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13321
13322
2/2
✓ Branch 0 taken 29580 times.
✓ Branch 1 taken 3570 times.
33150 if(customsfxdata[j].data!=NULL)
13323 {
13324 // delete [] customsfxdata[j].data;
13325 3570 free(customsfxdata[j].data);
13326 3570 }
13327
13328 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13329 33150 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13330 33150 customsfxdata[j].bits = temp_sample->bits;
13331 33150 customsfxdata[j].stereo = temp_sample->stereo;
13332 33150 customsfxdata[j].freq = temp_sample->freq;
13333 33150 customsfxdata[j].priority = temp_sample->priority;
13334 33150 customsfxdata[j].len = temp_sample->len;
13335 33150 customsfxdata[j].loop_start = temp_sample->loop_start;
13336 33150 customsfxdata[j].loop_end = temp_sample->loop_end;
13337 33150 customsfxdata[j].param = temp_sample->param;
13338 33150 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13339 33150 i=j;
13340 33150 }
13341 130 }
13342
13343 extern char *guy_string[eMAXGUYS];
13344 extern const char *old_guy_string[OLDMAXGUYS];
13345
13346 130 int32_t readguys(PACKFILE *f, zquestheader *Header)
13347 {
13348
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (should_skip) return 0;
13350
13351 dword dummy;
13352 word guy_cversion;
13353 130 word guyversion=0;
13354
13355
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version >= 0x193)
13356 {
13357 //section version info
13358
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&guyversion,f))
13359 {
13360 return qe_invalid;
13361 }
13362
13363 126 FFCore.quest_format[vGuys] = guyversion;
13364
13365 //al_trace("Guys version %d\n", guyversion);
13366
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&guy_cversion,f))
13367 {
13368 return qe_invalid;
13369 }
13370 126 al_trace("Guy CVersion is: %d\n", guy_cversion);
13371 //section size
13372
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
13373 {
13374 return qe_invalid;
13375 }
13376 126 }
13377
13378
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(guyversion > 3)
13379 {
13380
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<MAXGUYS; i++)
13381 {
13382 char tempname[64];
13383
13384 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13385 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13386
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58368 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13387 {
13388 memset(tempname, 0, sizeof(char)*64);
13389 sprintf(tempname, "e%03d", i);
13390 strcpy(guy_string[i], tempname);
13391
13392 continue;
13393 }
13394
13395
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!pfread(tempname, 64, f))
13396 {
13397 return qe_invalid;
13398 }
13399
13400 // Don't retain names of uneditable enemy entries!
13401 // for version upgrade to 2.5
13402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58368 if(guyversion < 23 && i >= 177)
13403 {
13404 // some of the older builds have names such as 'zz123',
13405 // (this order gets messed up with some eXXX and some zzXXX)
13406 // so let's update to the newer naming convection. -Gleeok
13407 char tmpbuf[64];
13408 memset(tmpbuf, 0, sizeof(char)*64);
13409 sprintf(tmpbuf, "zz%03d", i);
13410
13411 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13412 {
13413 memset(tempname, 0, sizeof(char)*64);
13414 sprintf(tempname, "e%03d", i);
13415 }
13416 }
13417
13418
6/6
✓ Branch 0 taken 20178 times.
✓ Branch 1 taken 38190 times.
✓ Branch 2 taken 19152 times.
✓ Branch 3 taken 1026 times.
✓ Branch 4 taken 16118 times.
✓ Branch 5 taken 3034 times.
58368 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13419 {
13420 55334 guy_string[i][0] = '\0';
13421 55334 strncat(guy_string[i], tempname, 64 - 1);
13422 55334 }
13423 else
13424 {
13425 3034 strcpy(guy_string[i],old_guy_string[i]);
13426 }
13427 58368 }
13428 114 }
13429 else
13430 {
13431
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13432 {
13433 8192 sprintf(guy_string[i],"zz%03d",i);
13434 8192 }
13435
13436
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13437 {
13438 2832 strcpy(guy_string[i],old_guy_string[i]);
13439 2832 }
13440 }
13441
13442
13443 //finally... section data
13444 130 init_guys(guyversion); //using default data for now...
13445
13446 // Goriya guy fix
13447
3/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13448 {
13449
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13450 {
13451 12 guysbuf[gGORIYA].tile=130;
13452 12 guysbuf[gGORIYA].e_tile=130;
13453 12 }
13454 16 }
13455
13456
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version < 0x193)
13457 {
13458
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13459 {
13460 guysbuf[eDODONGO].cset=14;
13461 guysbuf[eDODONGO].bosspal=spDIG;
13462 }
13463 4 }
13464 // Not sure when this first changed, but it's necessary for 2.10, at least
13465 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13466 //2.10 Fixes
13467
3/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13468 {
13469 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13470 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13471 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13472 16 guysbuf[eCENT1].misc3 = 1;
13473 16 guysbuf[eCENT2].misc3 = 1;
13474 16 }
13475
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13476 {
13477 130 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13478 130 }
13479
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if(Header->zelda_version <= 0x210)
13480 {
13481 16 guysbuf[eGLEEOK1F].misc6 = 16;
13482 16 guysbuf[eGLEEOK2F].misc6 = 16;
13483 16 guysbuf[eGLEEOK3F].misc6 = 16;
13484 16 guysbuf[eGLEEOK4F].misc6 = 16;
13485
13486 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13487 16 guysbuf[eBATROBE].misc4 = 1;
13488 //guysbuf[eSUMMONER].misc4 = 1;
13489 16 guysbuf[eWWIZ].misc4 = 1;
13490 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13491 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13492 16 }
13493
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version == 0x190)
13494 {
13495 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13496 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13497 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13498 4 }
13499
13500 // The versions here may not be correct
13501 // zelda_version>=0x211 handled at guyversion<24
13502
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version <= 0x190)
13503 {
13504 4 guysbuf[eCENT1].misc3 = 0;
13505 4 guysbuf[eCENT2].misc3 = 0;
13506 4 guysbuf[eMOLDORM].misc2 = 0;
13507 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13508 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13509 4 }
13510
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 12 times.
126 else if(Header->zelda_version <= 0x210)
13511 {
13512 12 guysbuf[eCENT1].misc3 = 1;
13513 12 guysbuf[eCENT2].misc3 = 1;
13514 12 guysbuf[eMOLDORM].misc2 = 0;
13515 12 }
13516
13517
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
130 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13518 {
13519 16 guysbuf[eKEESE1].misc16 = 120;
13520 16 guysbuf[eKEESE2].misc16 = 120;
13521 16 guysbuf[eKEESE3].misc16 = 120;
13522 16 guysbuf[eKEESETRIB].misc16 = 120;
13523 16 guysbuf[eKEESE1].misc17 = 16;
13524 16 guysbuf[eKEESE2].misc17 = 16;
13525 16 guysbuf[eKEESE3].misc17 = 16;
13526 16 guysbuf[eKEESETRIB].misc17 = 16;
13527
13528 16 guysbuf[ePEAHAT].misc16 = 80;
13529 16 guysbuf[ePEAHAT].misc17 = 16;
13530
13531 16 guysbuf[eGHINI2].misc16 = 120;
13532 16 guysbuf[eGHINI2].misc17 = 10;
13533
13534
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (replay_version_check(20))
13535 {
13536 guysbuf[eGHINI2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13537 guysbuf[eMOLDORM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13538 guysbuf[eKEESETRIB].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13539 guysbuf[eKEESE3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13540 guysbuf[eKEESE2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13541 guysbuf[eKEESE1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13542 guysbuf[eTEK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13543 guysbuf[eTEK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13544 guysbuf[ePEAHAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13545 guysbuf[eROCK].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13546 guysbuf[eTRAP].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13547 guysbuf[eWALLM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13548 guysbuf[ePOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13549 guysbuf[eMANHAN].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13550 guysbuf[eGLEEOK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13551 guysbuf[eGLEEOK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13552 guysbuf[eGLEEOK3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13553 guysbuf[eGLEEOK4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13554 guysbuf[eDIG1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13555 guysbuf[eDIG3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13556 guysbuf[eDIGPUP1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13557 guysbuf[eDIGPUP2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13558 guysbuf[eDIGPUP3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13559 guysbuf[eDIGPUP4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13560 guysbuf[eRAQUAM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13561 guysbuf[eITEMFAIRY].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13562 guysbuf[eFIRE].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13563 guysbuf[eMANHAN2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13564 guysbuf[eTRAP_H].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13565 guysbuf[eTRAP_V].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13566 guysbuf[eTRAP_LR].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13567 guysbuf[eTRAP_UD].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13568 guysbuf[ePATRA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13569 guysbuf[ePATRA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13570 guysbuf[ePATRABS].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13571 guysbuf[eBAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13572 guysbuf[eGLEEOK1F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13573 guysbuf[eGLEEOK2F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13574 guysbuf[eGLEEOK3F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13575 guysbuf[eGLEEOK4F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13576 guysbuf[eTRIGGER].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13577 guysbuf[ePATRAL2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13578 guysbuf[ePATRAL3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13579 guysbuf[eGOHMA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13580 guysbuf[eGOHMA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13581 guysbuf[eGOHMA3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13582 guysbuf[eGOHMA4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13583 guysbuf[eMPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13584 guysbuf[eWPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13585 }
13586 16 }
13587
13588
13589
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 114 times.
130 if(guyversion<=2)
13590 {
13591 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13592 }
13593
13594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(guyversion > 3)
13595 {
13596 guydata tempguy;
13597
13598
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<MAXGUYS; i++)
13599 {
13600
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 23) // May 2012 : 512 max enemies
13601 {
13602 if(i >= OLDBETAMAXGUYS)
13603 {
13604 memset(&guysbuf[i], 0, sizeof(guydata));
13605 continue;
13606 }
13607 }
13608
13609 58368 memset(&tempguy, 0, sizeof(guydata));
13610
13611
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.flags),f))
13612 {
13613 return qe_invalid;
13614 }
13615
13616
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.flags2),f))
13617 {
13618 return qe_invalid;
13619 }
13620
13621
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion >= 36 ) //expanded tiles
13622 {
13623
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.tile),f))
13624 {
13625 return qe_invalid;
13626 }
13627 18944 }
13628 else
13629 {
13630
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13631 {
13632 return qe_invalid;
13633 }
13634 }
13635
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.width),f))
13636 {
13637 return qe_invalid;
13638 }
13639
13640
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.height),f))
13641 {
13642 return qe_invalid;
13643 }
13644
13645
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion >= 36 ) //expanded tiles
13646 {
13647
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.s_tile),f))
13648 {
13649 return qe_invalid;
13650 }
13651 18944 }
13652 else
13653 {
13654
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13655 {
13656 return qe_invalid;
13657 }
13658 }
13659
13660
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.s_width),f))
13661 {
13662 return qe_invalid;
13663 }
13664
13665
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.s_height),f))
13666 {
13667 return qe_invalid;
13668 }
13669
13670
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion >= 36 ) //expanded tiles
13671 {
13672
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.e_tile),f))
13673 {
13674 return qe_invalid;
13675 }
13676 18944 }
13677 else
13678 {
13679
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13680 {
13681 return qe_invalid;
13682 }
13683 }
13684
13685
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.e_width),f))
13686 {
13687 return qe_invalid;
13688 }
13689
13690
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.e_height),f))
13691 {
13692 return qe_invalid;
13693 }
13694
13695
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.hp),f))
13696 {
13697 return qe_invalid;
13698 }
13699
13700
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.family),f))
13701 {
13702 return qe_invalid;
13703 }
13704
13705
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
58368 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13706 {
13707 if(get_qr(qr_NEWENEMYTILES))
13708 {
13709 tempguy.s_tile=tempguy.e_tile+120;
13710 tempguy.s_width=tempguy.e_width;
13711 tempguy.s_height=tempguy.e_height;
13712 }
13713 else tempguy.s_tile=860;
13714 }
13715
13716
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.cset),f))
13717 {
13718 return qe_invalid;
13719 }
13720
13721
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.anim),f))
13722 {
13723 return qe_invalid;
13724 }
13725
13726
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.e_anim),f))
13727 {
13728 return qe_invalid;
13729 }
13730
13731
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.frate),f))
13732 {
13733 return qe_invalid;
13734 }
13735
13736
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.e_frate),f))
13737 {
13738 return qe_invalid;
13739 }
13740
13741
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 13) // April 2009
13742 {
13743 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13744 {
13745 tempguy.frate *= 2;
13746 tempguy.e_frate *= 2;
13747 }
13748 }
13749
13750
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 14) // May 1 2009
13751 {
13752 if(tempguy.anim==a2FRMSLOW)
13753 {
13754 tempguy.anim=a2FRM;
13755 tempguy.frate *= 2;
13756 }
13757
13758 if(tempguy.e_anim==a2FRMSLOW)
13759 {
13760 tempguy.e_anim=a2FRM;
13761 tempguy.e_frate *= 2;
13762 }
13763
13764 if(tempguy.anim==aFLIPSLOW)
13765 {
13766 tempguy.anim=aFLIP;
13767 tempguy.frate *= 2;
13768 }
13769
13770 if(tempguy.e_anim==aFLIPSLOW)
13771 {
13772 tempguy.e_anim=aFLIP;
13773 tempguy.e_frate *= 2;
13774 }
13775
13776 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13777
13778 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13779
13780 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13781 {
13782 tempguy.anim=a4FRM4DIR;
13783 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13784 }
13785
13786 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13787 {
13788 tempguy.e_anim=a4FRM4DIR;
13789 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13790 }
13791 }
13792
13793
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.dp),f))
13794 {
13795 return qe_invalid;
13796 }
13797
13798 //correction for guy fire
13799
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 6)
13800 {
13801 if(i == gFIRE)
13802 tempguy.dp = 2;
13803 }
13804
13805
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.wdp),f))
13806 {
13807 return qe_invalid;
13808 }
13809
13810
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.weapon),f))
13811 {
13812 return qe_invalid;
13813 }
13814
13815 //correction for bosses using triple, "rising" fireballs
13816
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 5)
13817 {
13818 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13819 i == eGOHMA3 || i == eGOHMA4)
13820 {
13821 if(tempguy.weapon == ewFireball)
13822 tempguy.weapon = ewFireball2;
13823 }
13824 }
13825
13826
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.rate),f))
13827 {
13828 return qe_invalid;
13829 }
13830
13831
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.hrate),f))
13832 {
13833 return qe_invalid;
13834 }
13835
13836
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.step),f))
13837 {
13838 return qe_invalid;
13839 }
13840
13841 // HIGHLY UNORTHODOX UPDATING THING, part 2
13842
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 56832 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
58368 if(fixpolsvoice && tempguy.family==eePOLSV)
13843 {
13844 tempguy.step /= 2;
13845 }
13846
13847
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.homing),f))
13848 {
13849 return qe_invalid;
13850 }
13851
13852
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.grumble),f))
13853 {
13854 return qe_invalid;
13855 }
13856
13857
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.item_set),f))
13858 {
13859 return qe_invalid;
13860 }
13861
13862
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13863 {
13864
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc1),f))
13865 {
13866 return qe_invalid;
13867 }
13868
13869
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc2),f))
13870 {
13871 return qe_invalid;
13872 }
13873
13874
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc3),f))
13875 {
13876 return qe_invalid;
13877 }
13878
13879
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc4),f))
13880 {
13881 return qe_invalid;
13882 }
13883
13884
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc5),f))
13885 {
13886 return qe_invalid;
13887 }
13888
13889
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc6),f))
13890 {
13891 return qe_invalid;
13892 }
13893
13894
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc7),f))
13895 {
13896 return qe_invalid;
13897 }
13898
13899
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc8),f))
13900 {
13901 return qe_invalid;
13902 }
13903
13904
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc9),f))
13905 {
13906 return qe_invalid;
13907 }
13908
13909
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc10),f))
13910 {
13911 return qe_invalid;
13912 }
13913 58368 }
13914 else
13915 {
13916 int16_t tempMisc;
13917
13918 if(!p_igetw(&tempMisc,f))
13919 {
13920 return qe_invalid;
13921 }
13922
13923 tempguy.misc1=tempMisc;
13924
13925 if(!p_igetw(&tempMisc,f))
13926 {
13927 return qe_invalid;
13928 }
13929
13930 tempguy.misc2=tempMisc;
13931
13932 if(!p_igetw(&tempMisc,f))
13933 {
13934 return qe_invalid;
13935 }
13936
13937 tempguy.misc3=tempMisc;
13938
13939 if(!p_igetw(&tempMisc,f))
13940 {
13941 return qe_invalid;
13942 }
13943
13944 tempguy.misc4=tempMisc;
13945
13946 if(!p_igetw(&tempMisc,f))
13947 {
13948 return qe_invalid;
13949 }
13950
13951 tempguy.misc5=tempMisc;
13952
13953 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
13954 {
13955 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
13956 tempguy.misc5 = 74;
13957 }
13958
13959 if(!p_igetw(&tempMisc,f))
13960 {
13961 return qe_invalid;
13962 }
13963
13964 tempguy.misc6=tempMisc;
13965
13966 if(!p_igetw(&tempMisc,f))
13967 {
13968 return qe_invalid;
13969 }
13970
13971 tempguy.misc7=tempMisc;
13972
13973 if(!p_igetw(&tempMisc,f))
13974 {
13975 return qe_invalid;
13976 }
13977
13978 tempguy.misc8=tempMisc;
13979
13980 if(!p_igetw(&tempMisc,f))
13981 {
13982 return qe_invalid;
13983 }
13984
13985 tempguy.misc9=tempMisc;
13986
13987 if(!p_igetw(&tempMisc,f))
13988 {
13989 return qe_invalid;
13990 }
13991
13992 tempguy.misc10=tempMisc;
13993 }
13994
13995
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.bgsfx),f))
13996 {
13997 return qe_invalid;
13998 }
13999
14000
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.bosspal),f))
14001 {
14002 return qe_invalid;
14003 }
14004
14005
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetw(&(tempguy.extend),f))
14006 {
14007 return qe_invalid;
14008 }
14009
14010 //! Enemy Defences
14011
14012 //If a 2.50 quest, use only the 2.5 defences.
14013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
58368 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14014 {
14015
2/2
✓ Branch 0 taken 1108992 times.
✓ Branch 1 taken 58368 times.
1167360 for(int32_t j=0; j<edefLAST; j++)
14016 {
14017
1/2
✓ Branch 0 taken 1108992 times.
✗ Branch 1 not taken.
1108992 if(!p_getc(&(tempguy.defense[j]),f))
14018 {
14019 return qe_invalid;
14020 }
14021 1108992 }
14022 //then copy the generic script defence to all the new script defences
14023
14024 58368 }
14025
14026
14027
14028
14029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58368 times.
58368 if(guyversion >= 18)
14030 {
14031
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.hitsfx),f))
14032 {
14033 return qe_invalid;
14034 }
14035
14036
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_getc(&(tempguy.deadsfx),f))
14037 {
14038 return qe_invalid;
14039 }
14040 58368 }
14041
14042
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion >= 22)
14043 {
14044
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc11),f))
14045 {
14046 return qe_invalid;
14047 }
14048
14049
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(!p_igetl(&(tempguy.misc12),f))
14050 {
14051 return qe_invalid;
14052 }
14053 58368 }
14054 else if(guyversion >= 19)
14055 {
14056 int16_t tempMisc;
14057
14058 if(!p_igetw(&tempMisc,f))
14059 {
14060 return qe_invalid;
14061 }
14062
14063 tempguy.misc11=tempMisc;
14064
14065 if(!p_igetw(&tempMisc,f))
14066 {
14067 return qe_invalid;
14068 }
14069
14070 tempguy.misc12=tempMisc;
14071 }
14072
14073 //If a 2.54 or later quest, use all of the defences.
14074
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 24) // Add new guyversion conditional statement
14075 {
14076
2/2
✓ Branch 0 taken 416768 times.
✓ Branch 1 taken 18944 times.
435712 for(int32_t j=edefLAST; j<edefLAST255; j++)
14077 {
14078
1/2
✓ Branch 0 taken 416768 times.
✗ Branch 1 not taken.
416768 if(!p_getc(&(tempguy.defense[j]),f))
14079 {
14080 return qe_invalid;
14081 }
14082 416768 }
14083 18944 }
14084
14085
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14086 {
14087
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14088 {
14089 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14090 394240 }
14091 39424 }
14092
14093 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14094
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 25)
14095 {
14096
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.txsz),f))
14097 {
14098 return qe_invalid;
14099 }
14100
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.tysz),f))
14101 {
14102 return qe_invalid;
14103 }
14104
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hxsz),f))
14105 {
14106 return qe_invalid;
14107 }
14108
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hysz),f))
14109 {
14110 return qe_invalid;
14111 }
14112
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hzsz),f))
14113 {
14114 return qe_invalid;
14115 }
14116 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14117
14118 */
14119 18944 }
14120 //More Enemy Editor vars for 2.60
14121
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 26)
14122 {
14123
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hxofs),f))
14124 {
14125 return qe_invalid;
14126 }
14127
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.hyofs),f))
14128 {
14129 return qe_invalid;
14130 }
14131
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.xofs),f))
14132 {
14133 return qe_invalid;
14134 }
14135
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.yofs),f))
14136 {
14137 return qe_invalid;
14138 }
14139
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.zofs),f))
14140 {
14141 return qe_invalid;
14142 }
14143 18944 }
14144
14145
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14146 {
14147 39424 tempguy.wpnsprite = 0;
14148 39424 }
14149
14150
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 27)
14151 {
14152
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.wpnsprite),f))
14153 {
14154 return qe_invalid;
14155 }
14156 18944 }
14157
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14158 {
14159 39424 tempguy.SIZEflags = 0;
14160 39424 }
14161
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion > 28)
14162 {
14163
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.SIZEflags),f))
14164 {
14165 return qe_invalid;
14166 }
14167
14168 18944 }
14169
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14170 {
14171 39424 tempguy.frozentile = 0;
14172 39424 tempguy.frozencset = 0;
14173 39424 tempguy.frozenclock = 0;
14174
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14175 39424 }
14176
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion >= 30)
14177 {
14178
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.frozentile),f))
14179 {
14180 return qe_invalid;
14181 }
14182
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.frozencset),f))
14183 {
14184 return qe_invalid;
14185 }
14186
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.frozenclock),f))
14187 {
14188 return qe_invalid;
14189 }
14190
2/2
✓ Branch 0 taken 189440 times.
✓ Branch 1 taken 18944 times.
208384 for ( int32_t q = 0; q < 10; q++ ) {
14191
1/2
✓ Branch 0 taken 189440 times.
✗ Branch 1 not taken.
189440 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14192 {
14193 return qe_invalid;
14194 }
14195 189440 }
14196
14197 18944 }
14198
14199
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion >= 34)
14200 {
14201
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&(tempguy.firesfx),f))
14202 {
14203 return qe_invalid;
14204 }
14205
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc16),f))
14206 {
14207 return qe_invalid;
14208 }
14209
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc17),f))
14210 {
14211 return qe_invalid;
14212 }
14213
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc18),f))
14214 {
14215 return qe_invalid;
14216 }
14217
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc19),f))
14218 {
14219 return qe_invalid;
14220 }
14221
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc20),f))
14222 {
14223 return qe_invalid;
14224 }
14225
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc21),f))
14226 {
14227 return qe_invalid;
14228 }
14229
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc22),f))
14230 {
14231 return qe_invalid;
14232 }
14233
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc23),f))
14234 {
14235 return qe_invalid;
14236 }
14237
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc24),f))
14238 {
14239 return qe_invalid;
14240 }
14241
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc25),f))
14242 {
14243 return qe_invalid;
14244 }
14245
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc26),f))
14246 {
14247 return qe_invalid;
14248 }
14249
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc27),f))
14250 {
14251 return qe_invalid;
14252 }
14253
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc28),f))
14254 {
14255 return qe_invalid;
14256 }
14257
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc29),f))
14258 {
14259 return qe_invalid;
14260 }
14261
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc30),f))
14262 {
14263 return qe_invalid;
14264 }
14265
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc31),f))
14266 {
14267 return qe_invalid;
14268 }
14269
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc32),f))
14270 {
14271 return qe_invalid;
14272 }
14273
14274
2/2
✓ Branch 0 taken 606208 times.
✓ Branch 1 taken 18944 times.
625152 for ( int32_t q = 0; q < 32; q++ ) {
14275
1/2
✓ Branch 0 taken 606208 times.
✗ Branch 1 not taken.
606208 if(!p_igetl(&(tempguy.movement[q]),f))
14276 {
14277 return qe_invalid;
14278 }
14279 606208 }
14280
2/2
✓ Branch 0 taken 606208 times.
✓ Branch 1 taken 18944 times.
625152 for ( int32_t q = 0; q < 32; q++ ) {
14281
1/2
✓ Branch 0 taken 606208 times.
✗ Branch 1 not taken.
606208 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14282 {
14283 return qe_invalid;
14284 }
14285 606208 }
14286
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&(tempguy.script),f))
14287 {
14288 return qe_invalid;
14289 }
14290 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14291
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
14292 {
14293
1/2
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
151552 if(!p_igetl(&(tempguy.initD[q]),f))
14294 {
14295 return qe_invalid;
14296 }
14297 151552 }
14298
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 18944 times.
56832 for ( int32_t q = 0; q < 2; q++ )
14299 {
14300
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetl(&(tempguy.initA[q]),f))
14301 {
14302 return qe_invalid;
14303 }
14304 37888 }
14305
14306 18944 }
14307
14308
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion >= 37)
14309 {
14310
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.editorflags),f))
14311 {
14312 return qe_invalid;
14313 }
14314 18944 }
14315
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14316
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if(guyversion >= 38)
14317 {
14318
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc13),f))
14319 {
14320 return qe_invalid;
14321 }
14322
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc14),f))
14323 {
14324 return qe_invalid;
14325 }
14326
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetl(&(tempguy.misc15),f))
14327 {
14328 return qe_invalid;
14329 }
14330
14331 18944 }
14332
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion < 38 )
14333 {
14334 39424 tempguy.misc13 = 0;
14335 39424 tempguy.misc14 = 0;
14336 39424 tempguy.misc15 = 0;
14337 39424 }
14338
14339
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if ( guyversion >= 39 )
14340 {
14341
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
14342 {
14343
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; w++ )
14344 {
14345
1/2
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
9850880 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14346 {
14347 return qe_invalid;
14348 }
14349 9850880 }
14350
2/2
✓ Branch 0 taken 9850880 times.
✓ Branch 1 taken 151552 times.
10002432 for ( int32_t w = 0; w < 65; w++ )
14351 {
14352
1/2
✓ Branch 0 taken 9850880 times.
✗ Branch 1 not taken.
9850880 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14353 {
14354 return qe_invalid;
14355 }
14356 9850880 }
14357 151552 }
14358
14359
14360 18944 }
14361
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion < 39 ) //apply old InitD strings to both
14362 {
14363
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14364 {
14365 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14366 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14367 315392 }
14368 39424 }
14369
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if ( guyversion >= 40 )
14370 {
14371
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&(tempguy.weaponscript),f))
14372 {
14373 return qe_invalid;
14374 }
14375 18944 }
14376
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if ( guyversion < 40 )
14377 {
14378 39424 tempguy.weaponscript = 0;
14379 39424 }
14380 //eweapon script InitD
14381
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
58368 if ( guyversion >= 41 )
14382 {
14383
2/2
✓ Branch 0 taken 151552 times.
✓ Branch 1 taken 18944 times.
170496 for ( int32_t q = 0; q < 8; q++ )
14384 {
14385
1/2
✓ Branch 0 taken 151552 times.
✗ Branch 1 not taken.
151552 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14386 {
14387 return qe_invalid;
14388 }
14389 151552 }
14390
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if ( guy_cversion < 4 )
14391 {
14392 if ( tempguy.family == eeKEESE )
14393 {
14394
14395 if ( !tempguy.misc1 )
14396 {
14397 tempguy.misc16 = 120;
14398 tempguy.misc17 = 16;
14399
14400 }
14401 }
14402 if ( tempguy.family == eePEAHAT )
14403 {
14404 tempguy.misc16 = 80;
14405 tempguy.misc17 = 16;
14406 }
14407
14408 if ( tempguy.family == eeGHINI )
14409 {
14410 tempguy.misc16 = 120;
14411 tempguy.misc17 = 10;
14412 }
14413
14414 }
14415 18944 }
14416
14417
14418
14419 //default weapon sprites (quest version < 2.54)
14420 //port over old defaults -Z
14421
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 32)
14422 {
14423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14424 {
14425
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14426 {
14427 case wNone:
14428 32842 tempguy.wpnsprite = 0; break;
14429
14430 case wSword:
14431 case wBeam:
14432 case wBrang:
14433 case wBomb:
14434 case wSBomb:
14435 case wLitBomb:
14436 case wLitSBomb:
14437 case wArrow:
14438 case wFire:
14439 case wWhistle:
14440 case wBait:
14441 case wWand:
14442 case wMagic:
14443 case wCatching:
14444 case wWind:
14445 case wRefMagic:
14446 case wRefFireball:
14447 case wRefRock:
14448 case wHammer:
14449 case wHookshot:
14450 case wHSHandle:
14451 case wHSChain:
14452 case wSSparkle:
14453 case wFSparkle:
14454 case wSmack:
14455 case wPhantom:
14456 case wCByrna:
14457 case wRefBeam:
14458 case wStomp:
14459 case lwMax:
14460 case wScript1:
14461 case wScript2:
14462 case wScript3:
14463 case wScript4:
14464 case wScript5:
14465 case wScript6:
14466 case wScript7:
14467 case wScript8:
14468 case wScript9:
14469 case wScript10:
14470 case wIce:
14471 //Cannot use any of these weapons yet.
14472 tempguy.wpnsprite = -1;
14473 break;
14474
14475 case wEnemyWeapons:
14476 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14477
14478 302 case ewArrow: tempguy.wpnsprite = 19; break;
14479 314 case ewBrang: tempguy.wpnsprite = 4; break;
14480 931 case ewSword: tempguy.wpnsprite = 20; break;
14481 493 case ewRock: tempguy.wpnsprite = 18; break;
14482 912 case ewMagic: tempguy.wpnsprite = 21; break;
14483 80 case ewBomb: tempguy.wpnsprite = 78; break;
14484 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14485 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14486 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14487 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14488 759 case ewFlame: tempguy.wpnsprite = 35; break;
14489 106 case ewWind: tempguy.wpnsprite = 36; break;
14490 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14491 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14492 case ewIce: tempguy.wpnsprite = 83; break;
14493 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14494
14495
14496 default: break; //No assign.
14497 }
14498 39424 }
14499 39424 }
14500
14501 //default weapon fire sound (quest version < 2.54)
14502 //port over old defaults and zero new data. -Z
14503
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 34)
14504 {
14505
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14506 {
14507 1261568 tempguy.movement[q] = 0;
14508 1261568 tempguy.new_weapon[q] = 0;
14509
14510 1261568 }
14511
14512 //NPC Script attributes.
14513 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14514
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14515
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14516
14517 39424 tempguy.misc16 = 0;
14518 39424 tempguy.misc17 = 0;
14519 39424 tempguy.misc18 = 0;
14520 39424 tempguy.misc19 = 0;
14521 39424 tempguy.misc20 = 0;
14522 39424 tempguy.misc21 = 0;
14523 39424 tempguy.misc22 = 0;
14524 39424 tempguy.misc23 = 0;
14525 39424 tempguy.misc24 = 0;
14526 39424 tempguy.misc25 = 0;
14527 39424 tempguy.misc26 = 0;
14528 39424 tempguy.misc27 = 0;
14529 39424 tempguy.misc28 = 0;
14530 39424 tempguy.misc29 = 0;
14531 39424 tempguy.misc30 = 0;
14532 39424 tempguy.misc31 = 0;
14533 39424 tempguy.misc32 = 0;
14534
14535 //old default sounds
14536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14537 {
14538
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14539 {
14540 case wNone:
14541 32842 tempguy.firesfx = 0; break;
14542
14543 case wSword:
14544 case wBeam:
14545 case wBrang:
14546 case wBomb:
14547 case wSBomb:
14548 case wLitBomb:
14549 case wLitSBomb:
14550 case wArrow:
14551 case wFire:
14552 case wWhistle:
14553 case wBait:
14554 case wWand:
14555 case wMagic:
14556 case wCatching:
14557 case wWind:
14558 case wRefMagic:
14559 case wRefFireball:
14560 case wRefRock:
14561 case wHammer:
14562 case wHookshot:
14563 case wHSHandle:
14564 case wHSChain:
14565 case wSSparkle:
14566 case wFSparkle:
14567 case wSmack:
14568 case wPhantom:
14569 case wCByrna:
14570 case wRefBeam:
14571 case wStomp:
14572 case lwMax:
14573 case wScript1:
14574 case wScript2:
14575 case wScript3:
14576 case wScript4:
14577 case wScript5:
14578 case wScript6:
14579 case wScript7:
14580 case wScript8:
14581 case wScript9:
14582 case wScript10:
14583 case wIce:
14584 //Cannot use any of these weapons yet.
14585 tempguy.firesfx = -1;
14586 break;
14587
14588 case wEnemyWeapons:
14589 1303 case ewFireball: tempguy.firesfx = 40; break;
14590
14591 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14592 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14593 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14594 493 case ewRock: tempguy.firesfx = 51; break;
14595 912 case ewMagic: tempguy.firesfx = 32; break;
14596 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14597 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14598 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14599 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14600 363 case ewFireTrail: tempguy.firesfx = 13; break;
14601 759 case ewFlame: tempguy.firesfx = 13; break;
14602 106 case ewWind: tempguy.firesfx = 32; break;
14603 80 case ewFlame2: tempguy.firesfx = 13; break;
14604 case ewFlame2Trail: tempguy.firesfx = 13; break;
14605 case ewIce: tempguy.firesfx = 44; break;
14606 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14607
14608 //what about special attacks (e.g. summoning == 56)
14609 default: break; //No assign.
14610 }
14611 39424 }
14612 39424 }
14613
14614 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14615
4/6
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18944 times.
58368 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14616 {
14617
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14618 39424 }
14619 //Keese and bat halt rates.
14620
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18944 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
58368 if ( guyversion < 42 && guy_cversion < 4 )
14621 {
14622
14623
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14624 {
14625
14626
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14627 {
14628 326 tempguy.misc16 = 120;
14629 326 tempguy.misc17 = 16;
14630
14631 326 }
14632 529 }
14633
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14634 {
14635 167 tempguy.misc16 = 80;
14636 167 tempguy.misc17 = 16;
14637 167 }
14638
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14639 {
14640 77 tempguy.misc16 = 120;
14641 77 tempguy.misc17 = 10;
14642 77 }
14643
14644
14645 39424 }
14646
14647
14648 //miscellaneous other corrections
14649 //fix the mirror wizzrobe -DD
14650
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 7)
14651 {
14652 if(i == eMWIZ)
14653 {
14654 tempguy.misc2 = 0;
14655 tempguy.misc4 = 1;
14656 }
14657 }
14658
14659
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 8)
14660 {
14661 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14662 {
14663 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14664 tempguy.misc5 = 4; //neck length in segments
14665 tempguy.misc6 = 8; //neck offset from first body tile
14666 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14667 tempguy.misc8 = 168; //head offset from first body tile
14668 tempguy.misc9 = 228; //flying head offset from first body tile
14669
14670 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14671 {
14672 tempguy.misc6 += 10; //neck offset from first body tile
14673 tempguy.misc8 -= 12; //head offset from first body tile
14674 }
14675 }
14676 }
14677
14678
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14679 {
14680 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14681 tempguy.bosspal = spDIG;
14682 }
14683
14684
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 11) // December 2007 - Spinning Tile fix
14685 {
14686 if(tempguy.family==eeSPINTILE)
14687 {
14688 tempguy.flags |= guy_superman;
14689 tempguy.item_set = 0; // Don't drop items
14690 tempguy.step = 300;
14691 }
14692 }
14693
14694
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14695 {
14696 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14697 {
14698 if(tempguy.family==eeROPE)
14699 {
14700 tempguy.flags2 &= ~guy_flashing;
14701 }
14702 }
14703
14704 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14705 {
14706 if(tempguy.family==eeBUBBLE)
14707 {
14708 tempguy.flags2 &= ~guy_flashing;
14709 }
14710 }
14711
14712 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14713 {
14714 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14715 {
14716 tempguy.flags2 |= guy_blinking;
14717 }
14718
14719 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14720 {
14721 tempguy.flags2 |= guy_transparent;
14722 }
14723 }
14724 }
14725
14726
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14727 {
14728 if(i==gFIRE)
14729 {
14730 tempguy.e_anim = aFLIP;
14731 tempguy.e_frate = 24;
14732 }
14733
14734 if(i==gFAIRY)
14735 {
14736 tempguy.e_anim = a2FRM;
14737 tempguy.e_frate = 16;
14738 }
14739 }
14740
14741
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14742 {
14743 if(i==0) Z_message("Updating guys to version 16...\n");
14744
14745 update_guy_1(&tempguy);
14746
14747 if(i==eMPOLSV)
14748 {
14749 tempguy.defense[edefARROW] = edCHINK;
14750 tempguy.defense[edefMAGIC] = ed1HKO;
14751 tempguy.defense[edefREFMAGIC] = ed1HKO;
14752 }
14753 }
14754
14755
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 17) // December 2009
14756 {
14757 if(tempguy.family==eePROJECTILE)
14758 {
14759 tempguy.misc1 = 0;
14760 }
14761 }
14762
14763
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 18) // January 2010
14764 {
14765 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14766 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14767
14768 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14769 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14770
14771 if(tempguy.family == eeAQUA)
14772 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14773 else if(tempguy.family == eeMANHAN)
14774 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14775 else if(tempguy.family==eePATRA)
14776 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14777 else if(tempguy.family==eeGHOMA)
14778 {
14779 for(int32_t j=0; j<edefLAST; j++)
14780 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14781
14782 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
14783
14784 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14785
14786 tempguy.misc1--;
14787 }
14788 else if(tempguy.family == eeGLEEOK)
14789 {
14790 for(int32_t j=0; j<edefLAST; j++)
14791 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14792
14793 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14794 }
14795 else if(tempguy.family == eeARMOS)
14796 {
14797 tempguy.family=eeWALK;
14798 tempguy.hrate = 0;
14799 tempguy.misc10 = tempguy.misc1;
14800 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
14801 tempguy.misc9 = e9tARMOS;
14802 }
14803 else if(tempguy.family == eeGHINI && !tempguy.misc1)
14804 {
14805 tempguy.family=eeWALK;
14806 tempguy.hrate = 0;
14807 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
14808 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
14809 }
14810
14811 // Spawn animation flags
14812 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
14813 tempguy.flags |= guy_fadeflicker;
14814 else
14815 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
14816 }
14817
14818
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 20) // April 2010
14819 {
14820 if(tempguy.family == eeTRAP)
14821 {
14822 tempguy.misc2 = tempguy.misc10;
14823
14824 if(tempguy.misc10>=1)
14825 {
14826 tempguy.misc1++;
14827 }
14828
14829 tempguy.misc10 = 0;
14830 }
14831
14832 // Bomb Blast fix
14833 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14834 tempguy.weapon = ewLitBomb;
14835 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14836 tempguy.weapon = ewLitSBomb;
14837 }
14838
14839
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 21) // September 2011
14840 {
14841 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14842 {
14843 if(tempguy.family == eeKEESETRIB)
14844 {
14845 tempguy.family = eeKEESE;
14846 tempguy.misc2 = e2tKEESETRIB;
14847 tempguy.misc1 = 0;
14848 }
14849
14850 tempguy.rate = 2;
14851 tempguy.hrate = 8;
14852 tempguy.homing = 0;
14853 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
14854 }
14855 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14856 {
14857 if(tempguy.family == eePEAHAT)
14858 {
14859 tempguy.rate = 4;
14860 tempguy.step = 62;
14861 }
14862 else
14863 tempguy.step = 25;
14864
14865 tempguy.hrate = 8;
14866 tempguy.homing = 0;
14867 }
14868 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14869 {
14870 if(tempguy.family == eeMANHAN)
14871 tempguy.step=50;
14872
14873 tempguy.hrate = 16;
14874 tempguy.homing = 0;
14875 }
14876 else if(tempguy.family == eeGLEEOK)
14877 {
14878 tempguy.rate = 2;
14879 tempguy.homing = 0;
14880 tempguy.hrate = 9;
14881 tempguy.step=89;
14882 }
14883 else if(tempguy.family == eeGHINI)
14884 {
14885 tempguy.rate = 4;
14886 tempguy.hrate = 12;
14887 tempguy.step=62;
14888 tempguy.homing = 0;
14889 }
14890
14891 // Bigdig random rate fix
14892 if(tempguy.family==eeDIG && tempguy.misc10==1)
14893 {
14894 tempguy.rate = 2;
14895 }
14896 }
14897
14898
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(guyversion < 24) // November 2012
14899 {
14900 if(tempguy.family==eeLANM)
14901 tempguy.misc3 = 1;
14902 else if(tempguy.family==eeMOLD)
14903 tempguy.misc2 = 0;
14904 }
14905
14906
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14907 {
14908
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
14909 {
14910 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14911 38764 }
14912
14913 39424 }
14914 // does not seem to solve the issue!
14915
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if ( Header->zelda_version <= 0x210 )
14916 {
14917 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14918 if ( tempguy.family == eeDONGO )
14919 {
14920 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14921 }
14922 }
14923
14924
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion >= 42)
14925 {
14926
2/2
✓ Branch 0 taken 17920 times.
✓ Branch 1 taken 1024 times.
18944 if(guyversion >= 47)
14927 {
14928
1/2
✓ Branch 0 taken 17920 times.
✗ Branch 1 not taken.
17920 if(!p_igetl(&(tempguy.moveflags),f))
14929 {
14930 return qe_invalid;
14931 }
14932 17920 }
14933 else
14934 {
14935 byte fl;
14936
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
14937 {
14938 return qe_invalid;
14939 }
14940 1024 tempguy.moveflags = fl;
14941 }
14942 18944 }
14943 else
14944 {
14945
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
14946 {
14947 //No gravity; floats over pits
14948 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14949 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14950 //Special (bosses, etc)
14951 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14952 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14953 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14954 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
14955 30899 break;
14956 //No gravity, but falls in pits
14957 case eeLEV:
14958 518 tempguy.moveflags = FLAG_CAN_PITFALL;
14959 518 break;
14960 //Bosses that respect pits
14961 case eeDONGO:
14962 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
14963 278 break;
14964 case eeLANM:
14965 241 tempguy.moveflags = 0;
14966 241 break;
14967 //Gravity, floats over pits
14968 case eeWIZZ: case eeWALLM: case eeGHINI:
14969 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
14970 1202 break;
14971 //Gravity and falls in pits
14972 case eeWALK:
14973
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
14974 601 break;
14975 [[fallthrough]];
14976 case eeOTHER:
14977 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
14978 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
14979 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
14980 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
14981 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
14982 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
14983 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
14984 5685 }
14985 }
14986
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 43)
14987 {
14988
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
14989 {
14990 //No gravity; floats over pits
14991 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14992 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14993 //Special (bosses, etc)
14994 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14995 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14996 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14997 case eeWIZZ: case eeWALLM: case eeGHINI:
14998 //Gravity, floats over pits
14999 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15000 32101 tempguy.moveflags |= FLAG_CAN_PITWALK;
15001 32101 break;
15002 }
15003 39424 }
15004
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if (guyversion < 44)
15005 {
15006
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
15007 {
15008 370 tempguy.flags |= guy_fadeinstant;
15009 370 }
15010 39424 }
15011
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if (guyversion > 44)
15012 {
15013
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&(tempguy.spr_shadow),f))
15014 {
15015 return qe_invalid;
15016 }
15017
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&(tempguy.spr_death),f))
15018 {
15019 return qe_invalid;
15020 }
15021
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&(tempguy.spr_spawn),f))
15022 {
15023 return qe_invalid;
15024 }
15025 18944 }
15026 else
15027 {
15028
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15029 39424 tempguy.spr_death = iwDeath;
15030 39424 tempguy.spr_spawn = iwSpawn;
15031 }
15032
15033
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 39424 times.
58368 if(guyversion < 46)
15034 {
15035
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15036 {
15037 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15038 321 }
15039 39424 }
15040
15041
1/2
✓ Branch 0 taken 58368 times.
✗ Branch 1 not taken.
58368 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15042 {
15043 tempguy.script = 0;
15044 for(int q = 0; q < 8; ++q)
15045 tempguy.initD[q] = 0;
15046 }
15047 58368 guysbuf[i] = tempguy;
15048 58368 }
15049 114 }
15050
15051 114 return 0;
15052 130 }
15053
15054 void update_guy_1(guydata *tempguy) // November 2009
15055 {
15056 bool doesntcount = false;
15057 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15058
15059 switch(tempguy->family)
15060 {
15061 case 1: //eeWALK
15062 switch(tempguy->misc10)
15063 {
15064 case 0: //Stalfos
15065 if(tempguy->misc1==1) // Fires four projectiles at once
15066 tempguy->misc1=4;
15067
15068 break;
15069
15070 case 1: //Darknut
15071 goto darknuts;
15072 break;
15073 }
15074
15075 tempguy->misc10 = 0;
15076 break;
15077
15078 case 2: //eeSHOOT
15079 tempguy->family = eeWALK;
15080
15081 switch(tempguy->misc10)
15082 {
15083 case 0: //Octorok
15084 if(tempguy->misc1==1||tempguy->misc1==2)
15085 {
15086 tempguy->misc1=e1tFIREOCTO;
15087 tempguy->misc2=e2tFIREOCTO;
15088 }
15089 else tempguy->misc1 = 0;
15090
15091 tempguy->misc6=tempguy->misc4;
15092 tempguy->misc4=tempguy->misc3;
15093 tempguy->misc3=0;
15094 break;
15095
15096 case 1: // Moblin
15097 tempguy->misc1 = 0;
15098 break;
15099
15100 case 2: //Lynel
15101 tempguy->misc6=tempguy->misc1+1;
15102 tempguy->misc1=0;
15103 break;
15104
15105 case 3: //Stalfos 2
15106 if(tempguy->misc1==1) // Fires four projectiles at once
15107 tempguy->misc1=e1t4SHOTS;
15108 else tempguy->misc1 = 0;
15109
15110 break;
15111
15112 case 4: //Darknut 5
15113 darknuts:
15114 tempguy->defense[edefFIRE] = edIGNORE;
15115 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15116 tempguy->defense[edefHOOKSHOT] = 0;
15117 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15118 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15119
15120 if(tempguy->misc1==1)
15121 tempguy->misc1=2;
15122 else if(tempguy->misc1==2)
15123 {
15124 tempguy->misc4=tempguy->misc3;
15125 tempguy->misc3=tempguy->misc2;
15126 tempguy->misc2=e2tSPLIT;
15127 tempguy->misc1 = 0;
15128 }
15129 else tempguy->misc1 = 0;
15130
15131 tempguy->flags |= inv_front;
15132
15133 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15134 tempguy->flags |= guy_bkshield;
15135
15136 break;
15137 }
15138
15139 tempguy->misc10 = 0;
15140 break;
15141
15142 /*
15143 case 9: //eeARMOS
15144 tempguy->family = eeWALK;
15145 break;
15146 */
15147 case 11: //eeGEL
15148 case 33: //eeGELTRIB
15149 if(tempguy->family==33)
15150 {
15151 tempguy->misc4 = 1;
15152
15153 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15154 tempguy->misc3 = tempguy->misc2;
15155
15156 tempguy->misc2 = e2tTRIBBLE;
15157 }
15158 else
15159 {
15160 tempguy->misc4 = 0;
15161 tempguy->misc3 = 0;
15162 tempguy->misc2 = 0;
15163 }
15164
15165 tempguy->family = eeWALK;
15166
15167 if(tempguy->misc1)
15168 {
15169 tempguy->misc1=1;
15170 tempguy->weapon = ewFireTrail;
15171 }
15172
15173 break;
15174
15175 case 34: //eeZOLTRIB
15176 case 12: //eeZOL
15177 tempguy->misc4=tempguy->misc3;
15178 tempguy->misc3=tempguy->misc2;
15179 tempguy->family = eeWALK;
15180 tempguy->misc2=e2tSPLITHIT;
15181
15182 if(tempguy->misc1)
15183 {
15184 tempguy->misc1=1;
15185 tempguy->weapon = ewFireTrail;
15186 }
15187
15188 break;
15189
15190 case 13: //eeROPE
15191 tempguy->family = eeWALK;
15192 tempguy->misc9 = e9tROPE;
15193
15194 if(tempguy->misc1)
15195 {
15196 tempguy->misc4 = tempguy->misc3;
15197 tempguy->misc3 = tempguy->misc2;
15198 tempguy->misc2 = e2tBOMBCHU;
15199 }
15200
15201 tempguy->misc1 = 0;
15202 break;
15203
15204 case 14: //eeGORIYA
15205 tempguy->family = eeWALK;
15206
15207 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15208
15209 break;
15210
15211 case 17: //eeBUBBLE
15212 tempguy->family = eeWALK;
15213 tempguy->misc8 = tempguy->misc2;
15214 tempguy->misc7 = tempguy->misc1 + 1;
15215 tempguy->misc1 = tempguy->misc2 = 0;
15216
15217 //fallthrogh
15218 case eeTRAP:
15219 case eeROCK:
15220 doesntcount = true;
15221 break;
15222
15223 case 35: //eeVIRETRIB
15224 case 18: //eeVIRE
15225 tempguy->family = eeWALK;
15226 tempguy->misc4=tempguy->misc3;
15227 tempguy->misc3=tempguy->misc2;
15228 tempguy->misc2=e2tSPLITHIT;
15229 tempguy->misc9=e9tVIRE;
15230 break;
15231
15232 case 19: //eeLIKE
15233 tempguy->family = eeWALK;
15234 tempguy->misc7 = e7tEATITEMS;
15235 tempguy->misc8=95;
15236 break;
15237
15238 case 20: //eePOLSV
15239 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15240 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15241 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15242 tempguy->defense[edefARROW] = ed1HKO;
15243 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15244 tempguy->family = eeWALK;
15245 tempguy->misc9 = e9tPOLSVOICE;
15246 tempguy->rate = 4;
15247 tempguy->homing = 32;
15248 tempguy->hrate = 10;
15249 tempguy->grumble = 0;
15250 break;
15251
15252 case eeWIZZ:
15253 if(tempguy->misc4)
15254 {
15255 for(int32_t i=0; i < edefLAST; i++)
15256 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15257 }
15258 else
15259 {
15260 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15261 tempguy->defense[edefMAGIC] = edCHINK;
15262 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15263 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15264 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15265 }
15266
15267 break;
15268
15269 case eePEAHAT:
15270 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15271
15272 if(!(tempguy->flags & guy_bhit))
15273 tempguy->defense[edefBRANG] = edSTUNONLY;
15274
15275 break;
15276
15277 case eeLEV:
15278 tempguy->defense[edefSTOMP] = edCHINK;
15279 break;
15280 }
15281
15282 // Old flags
15283 if(tempguy->flags & guy_superman)
15284 {
15285 for(int32_t i = 0; i < edefLAST; i++)
15286 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15287 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15288 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15289 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15290 }
15291
15292 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15293
15294 if(doesntcount)
15295 tempguy->flags |= (guy_doesntcount);
15296 }
15297
15298
15299 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version)
15300 {
15301 byte tempbyte, padding;
15302 int32_t extras, secretcombos;
15303 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15305 {
15306 return qe_invalid;
15307 }
15308
15309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15310 return qe_invalid;
15311 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15312
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15313
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15314
15315
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15316 {
15317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15318 {
15319 return qe_invalid;
15320 }
15321
15322 6864 temp_mapscr->str=tempbyte;
15323 6864 }
15324 else
15325 {
15326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15327 {
15328 return qe_invalid;
15329 }
15330 }
15331
15332
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15333 {
15334 return qe_invalid;
15335 }
15336
15337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15338 {
15339 return qe_invalid;
15340 }
15341
15342
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15343 {
15344 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15345 93768 }
15346 else
15347 {
15348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15349 return qe_invalid;
15350 }
15351
15352
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15354 {
15355
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15356 {
15357 return qe_invalid;
15358 }
15359 6864 }
15360
15361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15362 {
15363 return qe_invalid;
15364 }
15365
15366
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15367 {
15368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15369 {
15370 return qe_invalid;
15371 }
15372 6864 }
15373
15374
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15375 {
15376
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15377 {
15378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15379 {
15380 return qe_invalid;
15381 }
15382 460224 }
15383 153408 }
15384 else
15385 {
15386 93768 temp_mapscr->tilewarptype[1]=0;
15387 93768 temp_mapscr->tilewarptype[2]=0;
15388 93768 temp_mapscr->tilewarptype[3]=0;
15389 }
15390
15391
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15392 {
15393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15394 {
15395 return qe_invalid;
15396 }
15397 240312 }
15398
15399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15400 {
15401 return qe_invalid;
15402 }
15403
15404 247176 temp_mapscr->warpreturnx[1]=0;
15405 247176 temp_mapscr->warpreturnx[2]=0;
15406 247176 temp_mapscr->warpreturnx[3]=0;
15407
15408
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15409 {
15410
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15411 {
15412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15413 {
15414 return qe_invalid;
15415 }
15416 460224 }
15417 153408 }
15418
15419
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15420 {
15421 return qe_invalid;
15422 }
15423
15424 247176 temp_mapscr->warpreturny[1]=0;
15425 247176 temp_mapscr->warpreturny[2]=0;
15426 247176 temp_mapscr->warpreturny[3]=0;
15427
15428
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15429 {
15430
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15431 {
15432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15433 {
15434 return qe_invalid;
15435 }
15436 460224 }
15437
15438
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15439 {
15440
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15441 {
15442 return qe_invalid;
15443 }
15444 153408 }
15445 else
15446 {
15447 byte temp;
15448
15449 if(!p_getc(&temp,f))
15450 {
15451 return qe_invalid;
15452 }
15453
15454 temp_mapscr->warpreturnc=temp<<8|temp;
15455 }
15456 153408 }
15457
15458
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15459
15460 {
15461 return qe_invalid;
15462 }
15463
15464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15465 {
15466 return qe_invalid;
15467 }
15468
15469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15470 {
15471 return qe_invalid;
15472 }
15473
15474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15475 {
15476 return qe_invalid;
15477 }
15478
15479
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15480 {
15481
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15482 {
15483 return qe_invalid;
15484 }
15485 153408 }
15486 else
15487 {
15488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15489 {
15490 return qe_invalid;
15491 }
15492
15493 93768 temp_mapscr->color = (word) tempbyte;
15494 }
15495
15496
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15497 {
15498 return qe_invalid;
15499 }
15500
15501
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15502 {
15503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15504 {
15505 return qe_invalid;
15506
15507 }
15508 988704 }
15509
15510
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15511 {
15512
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15513 {
15514 return qe_invalid;
15515 }
15516
15517 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15518
15519
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15520 {
15521 for(int32_t i=1; i<4; i++)
15522 {
15523 if(!p_getc(&(tempbyte),f))
15524 {
15525 return qe_invalid;
15526 }
15527
15528 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15529 }
15530 }
15531 else
15532 {
15533 93768 temp_mapscr->tilewarpdmap[1]=0;
15534 93768 temp_mapscr->tilewarpdmap[2]=0;
15535 93768 temp_mapscr->tilewarpdmap[3]=0;
15536 }
15537 93768 }
15538 else
15539 {
15540
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15541 {
15542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15543 {
15544 return qe_invalid;
15545 }
15546 613632 }
15547 }
15548
15549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15550 {
15551 return qe_invalid;
15552 }
15553
15554
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15555 {
15556
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15557 {
15558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15559 {
15560 return qe_invalid;
15561 }
15562 460224 }
15563 153408 }
15564 else
15565 {
15566 93768 temp_mapscr->tilewarpscr[1]=0;
15567 93768 temp_mapscr->tilewarpscr[2]=0;
15568 93768 temp_mapscr->tilewarpscr[3]=0;
15569 }
15570
15571
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15572 {
15573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15574 {
15575 return qe_invalid;
15576 }
15577 153408 }
15578 else
15579 {
15580 93768 temp_mapscr->tilewarpoverlayflags=0;
15581 }
15582
15583
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15584 {
15585 return qe_invalid;
15586 }
15587
15588
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15589 {
15590
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15591 {
15592 return qe_invalid;
15593 }
15594
15595 6864 }
15596
15597
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15598 {
15599 if(!p_getc(&padding,f))
15600 {
15601 return qe_invalid;
15602 }
15603 }
15604
15605
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15606 {
15607 /*
15608 if (!temp_mapscr->enemy[k])
15609 {
15610 continue;
15611 }
15612 */
15613
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15614 {
15615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15616 {
15617 return qe_invalid;
15618 }
15619
15620 68640 temp_mapscr->enemy[k]=tempbyte;
15621 68640 }
15622 else
15623 {
15624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15625 {
15626 return qe_invalid;
15627 }
15628 }
15629
15630
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15631 {
15632 //using enumerations here is dangerous
15633 //very easy to break old quests -DD
15634
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15635 {
15636 788 temp_mapscr->enemy[k]+=5;
15637 788 }
15638
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15639 {
15640 40 temp_mapscr->enemy[k]+=1;
15641 40 }
15642 68640 }
15643
15644
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15645 {
15646
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15647 {
15648 81175 temp_mapscr->enemy[k]+=10;
15649 81175 }
15650 937680 }
15651 //don't read in any invalid data
15652
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15653 {
15654 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15655 90 temp_mapscr->enemy[k] = 0;
15656 90 }
15657 2471760 }
15658
15659
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15660 {
15661 return qe_invalid;
15662 }
15663
15664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15665 {
15666 return qe_invalid;
15667 }
15668
15669
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15670 {
15671
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15672 {
15673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15674 {
15675 return qe_invalid;
15676 }
15677 460224 }
15678 153408 }
15679 else
15680 {
15681 93768 temp_mapscr->sidewarptype[1]=0;
15682 93768 temp_mapscr->sidewarptype[2]=0;
15683 93768 temp_mapscr->sidewarptype[3]=0;
15684 }
15685
15686
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15687 {
15688
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15689 {
15690 return qe_invalid;
15691 }
15692 153408 }
15693 else
15694 {
15695 93768 temp_mapscr->sidewarpoverlayflags=0;
15696 }
15697
15698
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15699 {
15700 return qe_invalid;
15701 }
15702
15703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15704 {
15705 return qe_invalid;
15706 }
15707
15708
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15709 {
15710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
15711 {
15712 return qe_invalid;
15713 }
15714 988704 }
15715
15716
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15717 {
15718 return qe_invalid;
15719 }
15720
15721
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15722 {
15723
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
15724 {
15725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15726 {
15727 return qe_invalid;
15728 }
15729 460224 }
15730 153408 }
15731 else
15732 {
15733 93768 temp_mapscr->sidewarpscr[1]=0;
15734 93768 temp_mapscr->sidewarpscr[2]=0;
15735 93768 temp_mapscr->sidewarpscr[3]=0;
15736 }
15737
15738
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15739 {
15740
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15741 {
15742 return qe_invalid;
15743 }
15744
15745 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15746
15747
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15748 {
15749 for(int32_t i=1; i<4; i++)
15750 {
15751 if(!p_getc(&(tempbyte),f))
15752 {
15753 return qe_invalid;
15754 }
15755
15756 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15757 }
15758 }
15759 else
15760 {
15761 93768 temp_mapscr->sidewarpdmap[1]=0;
15762 93768 temp_mapscr->sidewarpdmap[2]=0;
15763 93768 temp_mapscr->sidewarpdmap[3]=0;
15764 }
15765 93768 }
15766 else
15767 {
15768
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15769 {
15770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15771 {
15772 return qe_invalid;
15773 }
15774 613632 }
15775 }
15776
15777
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15778 {
15779
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15780 {
15781 return qe_invalid;
15782 }
15783 153408 }
15784 93768 else temp_mapscr->sidewarpindex = 0;
15785
15786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
15787 {
15788 return qe_invalid;
15789 }
15790
15791
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15792 {
15793
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
15794 {
15795 return qe_invalid;
15796 }
15797 6864 }
15798
15799
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15800 {
15801 return qe_invalid;
15802 }
15803
15804
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
15805 {
15806 return qe_invalid;
15807 }
15808
15809
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
15810 {
15811 return qe_invalid;
15812 }
15813
15814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
15815 {
15816 return qe_invalid;
15817 }
15818
15819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
15820 {
15821 return qe_invalid;
15822 }
15823
15824
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15825 //if (version>2)
15826 {
15827
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
15828 {
15829 return qe_invalid;
15830 }
15831 153408 }
15832
15833
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15834 {
15835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
15836 {
15837 return qe_invalid;
15838 }
15839
15840
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
15841 {
15842 return qe_invalid;
15843 }
15844
15845
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
15846 {
15847 return qe_invalid;
15848 }
15849
15850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
15851 {
15852 temp_mapscr->flags5 &= ~32;
15853 temp_mapscr->noreset |= 48;
15854 }
15855
15856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
15857 {
15858 if(temp_mapscr->noreset&1)
15859 {
15860 temp_mapscr->noreset|=8192;
15861 }
15862
15863 if(temp_mapscr->nocarry&1)
15864 {
15865 temp_mapscr->nocarry|=8192;
15866 temp_mapscr->nocarry&=~1;
15867 }
15868 }
15869 153408 }
15870 else
15871 {
15872 93768 temp_mapscr->flags5 = 0;
15873 93768 temp_mapscr->noreset = 0;
15874 93768 temp_mapscr->nocarry = 0;
15875 }
15876
15877
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15878 {
15879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
15880 {
15881 return qe_invalid;
15882 }
15883 153408 }
15884
15885
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
15886 {
15887
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
15888 {
15889 return qe_invalid;
15890 }
15891
15892
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
15893 {
15894 return qe_invalid;
15895 }
15896
15897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
15898 {
15899 return qe_invalid;
15900 }
15901
15902
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
15903 {
15904 return qe_invalid;
15905 }
15906
15907
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
15908 {
15909 return qe_invalid;
15910 }
15911 153408 }
15912 else
15913 {
15914 93768 temp_mapscr->csensitive=1;
15915 }
15916
15917
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
15918 {
15919
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
15920 {
15921 100 temp_mapscr->bosssfx=
15922
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15923 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15924 WAV_ROAR;
15925 100 }
15926
15927
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
15928 {
15929 91 temp_mapscr->oceansfx=WAV_SEA;
15930 91 }
15931
15932 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15933 ? 0 : WAV_SECRET;
15934
15935 93768 temp_mapscr->flags3 &= ~66; //64|2
15936 93768 temp_mapscr->flags2 &= ~32;
15937 93768 temp_mapscr->flags &= ~136; // 128|8
15938 93768 }
15939 else
15940 {
15941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
15942 {
15943 return qe_invalid;
15944 }
15945
15946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
15947 {
15948 return qe_invalid;
15949 }
15950
15951
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
15952 {
15953 return qe_invalid;
15954 }
15955 }
15956
15957
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
15958 {
15959 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
15960 93768 }
15961 else
15962 {
15963
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
15964 {
15965 return qe_invalid;
15966 }
15967 }
15968
15969
15970
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
15971 {
15972
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
15973 {
15974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
15975 {
15976 return qe_invalid;
15977 }
15978 1441872 }
15979
15980
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
15981 {
15982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
15983 {
15984 return qe_invalid;
15985 }
15986 1441872 }
15987 240312 }
15988
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
15989 {
15990 if(!p_getc(&(temp_mapscr->layermap[2]),f))
15991 {
15992 return qe_invalid;
15993 }
15994
15995 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
15996 {
15997 return qe_invalid;
15998 }
15999
16000 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16001 {
16002 return qe_invalid;
16003 }
16004
16005 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16006
16007 {
16008 return qe_invalid;
16009 }
16010 }
16011
16012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
16013 {
16014 for(int32_t k=0; k<6; k++)
16015 {
16016 if(!p_getc(&tempbyte,f)) //layerxsize
16017 {
16018 return qe_invalid;
16019 }
16020 }
16021
16022 for(int32_t k=0; k<6; k++)
16023 {
16024 if(!p_getc(&tempbyte,f)) //layerxspeed
16025 {
16026 return qe_invalid;
16027 }
16028 }
16029
16030 for(int32_t k=0; k<6; k++)
16031 {
16032 if(!p_getc(&tempbyte,f)) //layerxdelay
16033 {
16034 return qe_invalid;
16035 }
16036 }
16037
16038 for(int32_t k=0; k<6; k++)
16039 {
16040 if(!p_getc(&tempbyte,f)) //layerysize
16041 {
16042 return qe_invalid;
16043 }
16044 }
16045
16046 for(int32_t k=0; k<6; k++)
16047 {
16048 if(!p_getc(&tempbyte,f)) //layeryspeed
16049 {
16050 return qe_invalid;
16051 }
16052 }
16053
16054 for(int32_t k=0; k<6; k++)
16055 {
16056 if(!p_getc(&tempbyte,f)) //layerydelay
16057 {
16058 return qe_invalid;
16059 }
16060 }
16061 }
16062
16063
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16064 {
16065
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16066 {
16067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16068 {
16069 return qe_invalid;
16070 }
16071 1441872 }
16072 240312 }
16073
16074
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16075 {
16076
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16077 {
16078 if(!p_getc(&padding,f))
16079 {
16080 return qe_invalid;
16081 }
16082 }
16083
16084
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16085 {
16086 return qe_invalid;
16087 }
16088 240312 }
16089
16090
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16091 {
16092 6864 extras=15;
16093 6864 }
16094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16095 {
16096 extras=11;
16097 }
16098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16099 {
16100 extras=32;
16101 }
16102
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16103 {
16104 extras=64;
16105 }
16106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16107 {
16108 extras=62;
16109 }
16110 else
16111
16112 {
16113 240312 extras=0;
16114 }
16115
16116
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16117 {
16118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16119 {
16120 return qe_invalid;
16121 }
16122 102960 }
16123
16124
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16125 //if (version>3)
16126 {
16127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16128 {
16129 return qe_invalid;
16130 }
16131
16132
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16133 {
16134 return qe_invalid;
16135 }
16136 153408 }
16137 else
16138 {
16139 93768 temp_mapscr->nextmap=0;
16140 93768 temp_mapscr->nextscr=0;
16141 }
16142
16143
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16144 {
16145 6864 secretcombos=20;
16146 6864 }
16147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16148 {
16149 secretcombos=256;
16150 }
16151 else
16152 {
16153 240312 secretcombos=128;
16154 }
16155
16156
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16157 {
16158
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16159 {
16160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16161 {
16162 return qe_invalid;
16163 }
16164
16165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16166 {
16167 137280 temp_mapscr->secretcombo[k]=tempbyte;
16168 137280 }
16169 137280 }
16170 6864 }
16171 else
16172 {
16173
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16174 {
16175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16176 {
16177 return qe_invalid;
16178 }
16179
16180 30759936 }
16181 }
16182
16183
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16184 {
16185
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16186 {
16187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16188 {
16189 return qe_invalid;
16190 }
16191 30759936 }
16192
16193
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16194 {
16195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16196 {
16197 return qe_invalid;
16198 }
16199 30759936 }
16200 240312 }
16201
16202
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16203 {
16204 if(!p_getc(&padding,f))
16205 {
16206 return qe_invalid;
16207 }
16208 }
16209
16210
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<176; k++)
16211 {
16212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16213 {
16214 return qe_invalid;
16215 }
16216 43502976 }
16217
16218
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16219 {
16220 if(!p_getc(&padding,f))
16221 {
16222 return qe_invalid;
16223 }
16224
16225 if(!p_getc(&padding,f))
16226 {
16227 return qe_invalid;
16228 }
16229 }
16230
16231
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16232 {
16233
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<176; k++)
16234 {
16235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16236 {
16237 return qe_invalid;
16238 }
16239
16240
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16241 {
16242 if(!p_getc(&tempbyte,f))
16243 {
16244 return qe_invalid;
16245 }
16246
16247 if(!p_getc(&tempbyte,f))
16248 {
16249 return qe_invalid;
16250 }
16251
16252 if(!p_getc(&tempbyte,f))
16253 {
16254 return qe_invalid;
16255 }
16256 }
16257 42294912 }
16258 240312 }
16259
16260
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16261 {
16262
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<176; k++)
16263 {
16264
16265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16266 {
16267 return qe_invalid;
16268 }
16269 42294912 }
16270 240312 }
16271
16272
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16273 {
16274 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16275 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16276 6864 }
16277
16278
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16279 {
16280 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16281 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16282 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16283 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16284 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16285 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16286 6864 }
16287
16288
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16289 {
16290
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<176; k++)
16291 {
16292
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16293 {
16294 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16295 {
16296 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16297 }
16298 }
16299 else
16300 {
16301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16302 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16303 {
16304 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16305 1208064 }
16306
16307 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16308 }
16309
16310 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16311 1208064 }
16312 6864 }
16313
16314 /*if(version>12)
16315 {
16316 if(!p_getc(&(temp_mapscr->scrWidth),f))
16317 {
16318 return qe_invalid;
16319 }
16320 if(!p_getc(&(temp_mapscr->scrHeight),f))
16321 {
16322 return qe_invalid;
16323 }
16324 }*/
16325
16326
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16327 {
16328
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16329 {
16330 return qe_invalid;
16331 }
16332 153408 }
16333 else
16334 {
16335 93768 temp_mapscr->screen_midi = -1;
16336 }
16337
16338
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16339 {
16340
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16341 {
16342 return qe_invalid;
16343 }
16344 153408 }
16345 else
16346 {
16347 93768 temp_mapscr->lens_layer = llNORMAL;
16348 }
16349
16350
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16351 {
16352 dword bits;
16353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16354 {
16355 return qe_invalid;
16356 }
16357
16358 int32_t m;
16359 float tempfloat;
16360 word tempw;
16361 153408 temp_mapscr->ffcCountMarkDirty();
16362
16363
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16364 {
16365 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16366 4909056 tempffc.clear();
16367
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16368 {
16369
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16370 {
16371 return qe_invalid;
16372 }
16373 22989 tempffc.data = tempw;
16374
16375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16376 {
16377 return qe_invalid;
16378 }
16379
16380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16381 {
16382 return qe_invalid;
16383 }
16384
16385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16386 {
16387 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16388 {
16389 return qe_invalid;
16390 }
16391
16392 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16393
16394 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16395 {
16396 return qe_invalid;
16397 }
16398
16399 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16400
16401 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16402 {
16403 return qe_invalid;
16404 }
16405
16406 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16407
16408 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16409 {
16410 return qe_invalid;
16411 }
16412
16413 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16414
16415 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16416 {
16417 return qe_invalid;
16418 }
16419
16420 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16421
16422 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16423 {
16424 return qe_invalid;
16425 }
16426
16427 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16428 }
16429 else
16430 {
16431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16432 {
16433 return qe_invalid;
16434 }
16435
16436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16437 {
16438 return qe_invalid;
16439 }
16440
16441
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16442 {
16443 return qe_invalid;
16444 }
16445
16446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16447 {
16448 return qe_invalid;
16449 }
16450
16451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16452 {
16453 return qe_invalid;
16454 }
16455
16456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16457 {
16458 return qe_invalid;
16459 }
16460 }
16461
16462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16463 {
16464 return qe_invalid;
16465 }
16466
16467
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16468 {
16469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16470 {
16471 return qe_invalid;
16472 }
16473
16474 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16475 22989 tempffc.txsz = (tempbyte>>6)+1;
16476
16477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16478 {
16479 return qe_invalid;
16480 }
16481
16482 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16483 22989 tempffc.tysz = (tempbyte>>6)+1;
16484
16485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16486 {
16487 return qe_invalid;
16488 }
16489 22989 }
16490 else
16491 {
16492 tempffc.hit_width=16;
16493 tempffc.hit_height=16;
16494 tempffc.txsz=1;
16495 tempffc.tysz=1;
16496 tempffc.flags=0;
16497 }
16498
16499 22989 tempffc.updateSolid();
16500
16501
16502
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16503 {
16504 tempffc.flags|=ffIGNOREHOLDUP;
16505 }
16506
16507
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16508 {
16509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16510 {
16511 return qe_invalid;
16512 }
16513 22989 }
16514 else
16515 {
16516 tempffc.script=0;
16517 }
16518
16519
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16520 {
16521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16522 {
16523 return qe_invalid;
16524 }
16525
16526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16527 {
16528 return qe_invalid;
16529 }
16530
16531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16532 {
16533 return qe_invalid;
16534 }
16535
16536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16537 {
16538 return qe_invalid;
16539 }
16540
16541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16542 {
16543 return qe_invalid;
16544 }
16545
16546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16547 {
16548 return qe_invalid;
16549 }
16550
16551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16552 {
16553 return qe_invalid;
16554 }
16555
16556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16557 {
16558 return qe_invalid;
16559 }
16560
16561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16562 {
16563 return qe_invalid;
16564 }
16565
16566 22989 tempffc.inita[0]=tempbyte*10000;
16567
16568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16569 {
16570 return qe_invalid;
16571 }
16572
16573 22989 tempffc.inita[1]=tempbyte*10000;
16574 22989 }
16575 else
16576 {
16577 tempffc.inita[0] = 10000;
16578 tempffc.inita[1] = 10000;
16579 }
16580
16581
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16582 {
16583 tempffc.script = 0;
16584 for(int q = 0; q < 8; ++q)
16585 tempffc.initd[q] = 0;
16586 }
16587
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16588 {
16589 fixffcs=true;
16590 }
16591 22989 }
16592 4909056 }
16593
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16594 {
16595 14727168 temp_mapscr->ffcs[m].clear();
16596 14727168 }
16597 153408 }
16598
16599 //add in the new whistle flags
16600
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16601 {
16602
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16603 {
16604 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16605 19 }
16606 93768 }
16607
16608 //2.55 starts here
16609
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16610 {
16611
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16612 {
16613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16614 {
16615 return qe_invalid;
16616 }
16617 137360 }
16618
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16619 {
16620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16621 {
16622 return qe_invalid;
16623 }
16624 137360 }
16625
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16626 {
16627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16628 {
16629 return qe_invalid;
16630 }
16631 137360 }
16632
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16633 {
16634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16635 {
16636 return qe_invalid;
16637 }
16638 137360 }
16639 13736 }
16640
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16641 {
16642 for ( int32_t q = 0; q < 10; q++ )
16643 {
16644 temp_mapscr->npcstrings[q] = 0;
16645 temp_mapscr->new_items[q] = 0;
16646 temp_mapscr->new_item_x[q] = 0;
16647 temp_mapscr->new_item_y[q] = 0;
16648 }
16649 }
16650
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16651 {
16652
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16653 {
16654 return qe_invalid;
16655 }
16656
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16657 {
16658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16659 {
16660 return qe_invalid;
16661 }
16662 109888 }
16663 13736 }
16664
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16665 {
16666 233440 temp_mapscr->script = 0;
16667
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16668 233440 }
16669
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16670 {
16671
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16672 {
16673 return qe_invalid;
16674 }
16675 13736 }
16676
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16677 {
16678 233440 temp_mapscr->preloadscript = 0;
16679 233440 }
16680 //all builds with version > 20 need this. -Z
16681
16682
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16683 {
16684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16685 {
16686 return qe_invalid;
16687 }
16688
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16689 {
16690 return qe_invalid;
16691 }
16692 13736 }
16693
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16694 {
16695 233440 temp_mapscr->hidelayers = 0;
16696 233440 temp_mapscr->hidescriptlayers = 0;
16697 233440 }
16698
16699 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16700 //May be any version before 2.11. -Z
16701 /* --not the roar, the HIT SFX
16702 if ( Header->zelda_version <= 0x210 )
16703 {
16704 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16705 {
16706 temp_mapscr->bosssfx = WAV_ROAR;
16707 }
16708 }
16709 */
16710
16711 247176 return 0;
16712 247176 }
16713 257648 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16714 {
16715
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 10472 times.
257648 if(version < 23)
16716 {
16717 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,version);
16718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
16719 247176 }
16720 else
16721 {
16722
1/2
✓ Branch 0 taken 10472 times.
✗ Branch 1 not taken.
10472 if(!p_getc(&(temp_mapscr->valid),f))
16723 return qe_invalid;
16724
2/2
✓ Branch 0 taken 8681 times.
✓ Branch 1 taken 1791 times.
10472 if(!(temp_mapscr->valid & mVALID))
16725 {
16726 8681 int map = scrind/MAPSCRS;
16727 8681 int scr = scrind%MAPSCRS;
16728
4/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 1679 times.
✓ Branch 2 taken 7002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7002 times.
✗ Branch 5 not taken.
8681 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16729 {
16730 //Empty screen, apply autolayers
16731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7002 times.
7002 for(int q = 0; q < 6; ++q)
16732 {
16733 auto layermap = map_autolayers[map*6+q];
16734 temp_mapscr->layermap[q] = layermap;
16735 if(layermap)
16736 temp_mapscr->layerscreen[q] = scr;
16737 }
16738 7002 }
16739 8681 return 0;
16740 }
16741 uint32_t scr_has_flags;
16742
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_igetl(&scr_has_flags,f))
16743 return qe_invalid;
16744
16745
2/2
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 916 times.
1791 if(scr_has_flags & SCRHAS_ROOMDATA)
16746 {
16747
1/2
✓ Branch 0 taken 916 times.
✗ Branch 1 not taken.
916 if(!p_getc(&(temp_mapscr->guy),f))
16748 return qe_invalid;
16749
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 30 times.
916 if(version > 26)
16750 {
16751
1/2
✓ Branch 0 taken 886 times.
✗ Branch 1 not taken.
886 if(!p_igetl(&(temp_mapscr->guytile),f))
16752 return qe_invalid;
16753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 886 times.
886 if(!p_getc(&(temp_mapscr->guycs),f))
16754 return qe_invalid;
16755
1/2
✓ Branch 0 taken 886 times.
✗ Branch 1 not taken.
886 if(!p_igetw(&(temp_mapscr->roomflags),f))
16756 return qe_invalid;
16757 886 }
16758 else
16759 {
16760 30 temp_mapscr->guytile = -1; //signal to use default guy values
16761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16762
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16763 }
16764
1/2
✓ Branch 0 taken 916 times.
✗ Branch 1 not taken.
916 if(!p_igetw(&(temp_mapscr->str),f))
16765 return qe_invalid;
16766
1/2
✓ Branch 0 taken 916 times.
✗ Branch 1 not taken.
916 if(!p_getc(&(temp_mapscr->room),f))
16767 return qe_invalid;
16768
1/2
✓ Branch 0 taken 916 times.
✗ Branch 1 not taken.
916 if(!p_igetw(&(temp_mapscr->catchall),f))
16769 return qe_invalid;
16770 916 }
16771
2/2
✓ Branch 0 taken 1741 times.
✓ Branch 1 taken 50 times.
1791 if(scr_has_flags & SCRHAS_ITEM)
16772 {
16773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!p_getc(&(temp_mapscr->item),f))
16774 return qe_invalid;
16775
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!p_getc(&(temp_mapscr->hasitem),f))
16776 return qe_invalid;
16777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!p_getc(&(temp_mapscr->itemx),f))
16778 return qe_invalid;
16779
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!p_getc(&(temp_mapscr->itemy),f))
16780 return qe_invalid;
16781 50 }
16782
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 127 times.
1791 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16783 {
16784
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16785 return qe_invalid;
16786 127 }
16787
2/2
✓ Branch 0 taken 1714 times.
✓ Branch 1 taken 77 times.
1791 if(scr_has_flags & SCRHAS_TWARP)
16788 {
16789
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
16790 {
16791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16792 return qe_invalid;
16793 308 }
16794
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
16795 {
16796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16797 return qe_invalid;
16798 308 }
16799
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
16800 {
16801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16802 return qe_invalid;
16803 308 }
16804
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16805 return qe_invalid;
16806 77 }
16807
2/2
✓ Branch 0 taken 1737 times.
✓ Branch 1 taken 54 times.
1791 if(scr_has_flags & SCRHAS_SWARP)
16808 {
16809
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 54 times.
270 for(int32_t i=0; i<4; i++)
16810 {
16811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16812 return qe_invalid;
16813 216 }
16814
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 54 times.
270 for(int32_t i=0; i<4; i++)
16815 {
16816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16817 return qe_invalid;
16818 216 }
16819
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 54 times.
270 for(int32_t i=0; i<4; i++)
16820 {
16821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16822 return qe_invalid;
16823 216 }
16824
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16825 return qe_invalid;
16826
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16827 return qe_invalid;
16828 54 }
16829
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 261 times.
1791 if(scr_has_flags & SCRHAS_WARPRET)
16830 {
16831
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 261 times.
1305 for(int32_t i=0; i<4; i++)
16832 {
16833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1044 times.
1044 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16834 return qe_invalid;
16835 1044 }
16836
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 261 times.
1305 for(int32_t i=0; i<4; i++)
16837 {
16838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1044 times.
1044 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16839 return qe_invalid;
16840 1044 }
16841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
261 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16842 return qe_invalid;
16843
1/2
✓ Branch 0 taken 261 times.
✗ Branch 1 not taken.
261 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16844 return qe_invalid;
16845 261 }
16846
2/2
✓ Branch 0 taken 1308 times.
✓ Branch 1 taken 483 times.
1791 if(scr_has_flags & SCRHAS_LAYERS)
16847 {
16848
2/2
✓ Branch 0 taken 2898 times.
✓ Branch 1 taken 483 times.
3381 for(int32_t k=0; k<6; k++)
16849 {
16850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2898 times.
2898 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16851 return qe_invalid;
16852 2898 }
16853
2/2
✓ Branch 0 taken 2898 times.
✓ Branch 1 taken 483 times.
3381 for(int32_t k=0; k<6; k++)
16854 {
16855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2898 times.
2898 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16856 return qe_invalid;
16857 2898 }
16858
2/2
✓ Branch 0 taken 2898 times.
✓ Branch 1 taken 483 times.
3381 for(int32_t k=0; k<6; k++)
16859 {
16860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2898 times.
2898 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16861 return qe_invalid;
16862 2898 }
16863
1/2
✓ Branch 0 taken 483 times.
✗ Branch 1 not taken.
483 if(!p_getc(&(temp_mapscr->hidelayers),f))
16864 return qe_invalid;
16865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483 times.
483 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16866 return qe_invalid;
16867 483 }
16868
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(scr_has_flags & SCRHAS_MAZE)
16869 {
16870 for(int32_t k=0; k<4; k++)
16871 {
16872 if(!p_getc(&(temp_mapscr->path[k]),f))
16873 return qe_invalid;
16874 }
16875 if(!p_getc(&(temp_mapscr->exitdir),f))
16876 return qe_invalid;
16877 }
16878
2/2
✓ Branch 0 taken 1640 times.
✓ Branch 1 taken 151 times.
1791 if(scr_has_flags & SCRHAS_D_S_U)
16879 {
16880
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16881 return qe_invalid;
16882
2/2
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 151 times.
755 for(int32_t k=0; k<4; k++)
16883 {
16884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
604 if(!p_getc(&(temp_mapscr->door[k]),f))
16885 return qe_invalid;
16886 604 }
16887
16888
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_mapscr->stairx),f))
16889 return qe_invalid;
16890
16891
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_mapscr->stairy),f))
16892 return qe_invalid;
16893
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_igetw(&(temp_mapscr->undercombo),f))
16894 return qe_invalid;
16895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(!p_getc(&(temp_mapscr->undercset),f))
16896 return qe_invalid;
16897 151 }
16898
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 177 times.
1791 if(scr_has_flags & SCRHAS_FLAGS)
16899 {
16900
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&(temp_mapscr->flags),f))
16901 return qe_invalid;
16902
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&(temp_mapscr->flags2),f))
16903 return qe_invalid;
16904
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&(temp_mapscr->flags3),f))
16905 return qe_invalid;
16906
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&(temp_mapscr->flags4),f))
16907 return qe_invalid;
16908
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&(temp_mapscr->flags5),f))
16909 return qe_invalid;
16910
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&(temp_mapscr->flags6),f))
16911 return qe_invalid;
16912
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&(temp_mapscr->flags7),f))
16913 return qe_invalid;
16914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if(!p_getc(&(temp_mapscr->flags8),f))
16915 return qe_invalid;
16916
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&(temp_mapscr->flags9),f))
16917 return qe_invalid;
16918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if(!p_getc(&(temp_mapscr->flags10),f))
16919 return qe_invalid;
16920
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&(temp_mapscr->enemyflags),f))
16921 return qe_invalid;
16922 177 }
16923
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 114 times.
1791 if(scr_has_flags & SCRHAS_ENEMY)
16924 {
16925
2/2
✓ Branch 0 taken 1140 times.
✓ Branch 1 taken 114 times.
1254 for(int32_t k=0; k<10; k++)
16926 {
16927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16928 return qe_invalid;
16929
1/2
✓ Branch 0 taken 1140 times.
✗ Branch 1 not taken.
1140 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16930 temp_mapscr->enemy[k] = 0;
16931 1140 }
16932
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&(temp_mapscr->pattern),f))
16933 return qe_invalid;
16934 114 }
16935
2/2
✓ Branch 0 taken 1787 times.
✓ Branch 1 taken 4 times.
1791 if(scr_has_flags & SCRHAS_CARRY)
16936 {
16937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetw(&(temp_mapscr->noreset),f))
16938 return qe_invalid;
16939
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&(temp_mapscr->nocarry),f))
16940 return qe_invalid;
16941
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->nextmap),f))
16942 return qe_invalid;
16943
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->nextscr),f))
16944 return qe_invalid;
16945 4 }
16946
2/2
✓ Branch 0 taken 1735 times.
✓ Branch 1 taken 56 times.
1791 if(scr_has_flags & SCRHAS_SCRIPT)
16947 {
16948
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(!p_igetw(&(temp_mapscr->script),f))
16949 return qe_invalid;
16950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(!p_getc(&(temp_mapscr->preloadscript),f))
16951 return qe_invalid;
16952
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 56 times.
504 for ( int32_t q = 0; q < 8; q++ )
16953 {
16954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 448 times.
448 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16955 return qe_invalid;
16956 448 }
16957 56 }
16958
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(scr_has_flags & SCRHAS_UNUSED)
16959 {
16960 for ( int32_t q = 0; q < 10; q++ )
16961 {
16962 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16963 return qe_invalid;
16964 }
16965 for ( int32_t q = 0; q < 10; q++ )
16966 {
16967 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16968 return qe_invalid;
16969 }
16970 for ( int32_t q = 0; q < 10; q++ )
16971 {
16972 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16973 return qe_invalid;
16974 }
16975 for ( int32_t q = 0; q < 10; q++ )
16976 {
16977 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16978 return qe_invalid;
16979 }
16980 }
16981
2/2
✓ Branch 0 taken 1609 times.
✓ Branch 1 taken 182 times.
1791 if(scr_has_flags & SCRHAS_SECRETS)
16982 {
16983
2/2
✓ Branch 0 taken 23296 times.
✓ Branch 1 taken 182 times.
23478 for(int32_t k=0; k<128; k++)
16984 {
16985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23296 times.
23296 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16986 return qe_invalid;
16987 23296 }
16988
2/2
✓ Branch 0 taken 23296 times.
✓ Branch 1 taken 182 times.
23478 for(int32_t k=0; k<128; k++)
16989 {
16990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23296 times.
23296 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16991 return qe_invalid;
16992 23296 }
16993
2/2
✓ Branch 0 taken 23296 times.
✓ Branch 1 taken 182 times.
23478 for(int32_t k=0; k<128; k++)
16994 {
16995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23296 times.
23296 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16996 return qe_invalid;
16997 23296 }
16998 182 }
16999
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 1369 times.
1791 if(scr_has_flags & SCRHAS_COMBOFLAG)
17000 {
17001
2/2
✓ Branch 0 taken 240944 times.
✓ Branch 1 taken 1369 times.
242313 for(int32_t k=0; k<176; ++k)
17002 {
17003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240944 times.
240944 if(!p_igetw(&(temp_mapscr->data[k]),f))
17004 return qe_invalid;
17005 240944 }
17006
2/2
✓ Branch 0 taken 240944 times.
✓ Branch 1 taken 1369 times.
242313 for(int32_t k=0; k<176; ++k)
17007 {
17008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240944 times.
240944 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17009 return qe_invalid;
17010 240944 }
17011
2/2
✓ Branch 0 taken 240944 times.
✓ Branch 1 taken 1369 times.
242313 for(int32_t k=0; k<176; ++k)
17012 {
17013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240944 times.
240944 if(!p_getc(&(temp_mapscr->cset[k]),f))
17014 return qe_invalid;
17015 240944 }
17016 1369 }
17017
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(scr_has_flags & SCRHAS_MISC)
17018 {
17019
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_igetw(&(temp_mapscr->color),f))
17020 return qe_invalid;
17021
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_getc(&(temp_mapscr->csensitive),f))
17022 return qe_invalid;
17023
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_getc(&(temp_mapscr->oceansfx),f))
17024 return qe_invalid;
17025
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_getc(&(temp_mapscr->bosssfx),f))
17026 return qe_invalid;
17027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1791 times.
1791 if(!p_getc(&(temp_mapscr->secretsfx),f))
17028 return qe_invalid;
17029
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17030 return qe_invalid;
17031
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17032 return qe_invalid;
17033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1791 times.
1791 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17034 return qe_invalid;
17035
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_getc(&(temp_mapscr->lens_layer),f))
17036 return qe_invalid;
17037
2/2
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 886 times.
1791 if(version > 27)
17038 {
17039
1/2
✓ Branch 0 taken 886 times.
✗ Branch 1 not taken.
886 if(!p_getc(&(temp_mapscr->lens_show),f))
17040 return qe_invalid;
17041
1/2
✓ Branch 0 taken 886 times.
✗ Branch 1 not taken.
886 if(!p_getc(&(temp_mapscr->lens_hide),f))
17042 return qe_invalid;
17043 886 }
17044 1791 }
17045 else
17046 {
17047 temp_mapscr->screen_midi = -1;
17048 temp_mapscr->csensitive = 1;
17049 }
17050 //FFC
17051 1791 bool old_ff = version < 25;
17052 1791 dword bits = 0;
17053 1791 word numffc = 32;
17054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1791 times.
1791 if(old_ff)
17055 {
17056 if(!p_igetl(&bits,f))
17057 return qe_invalid;
17058 }
17059 else
17060 {
17061
1/2
✓ Branch 0 taken 1791 times.
✗ Branch 1 not taken.
1791 if(!p_igetw(&numffc,f))
17062 return qe_invalid;
17063 }
17064 byte tempbyte;
17065 word tempw;
17066
4/6
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1758 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
1791 static ffcdata nil_ffc;
17067 1791 temp_mapscr->ffcCountMarkDirty();
17068
2/2
✓ Branch 0 taken 1791 times.
✓ Branch 1 taken 4124 times.
5915 for(word m = 0; m < numffc; ++m)
17069 {
17070
1/2
✓ Branch 0 taken 4124 times.
✗ Branch 1 not taken.
4124 ffcdata& tempffc = (m < MAXFFCS)
17071 4124 ? temp_mapscr->ffcs[m]
17072 : nil_ffc; //sanity
17073 4124 tempffc.clear();
17074
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4124 if(old_ff && !(bits & (1<<m))) continue;
17075
17076
1/2
✓ Branch 0 taken 4124 times.
✗ Branch 1 not taken.
4124 if(!p_igetw(&tempw,f))
17077 return qe_invalid;
17078
3/4
✓ Branch 0 taken 4124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1509 times.
✓ Branch 3 taken 2615 times.
4124 if(!old_ff && !tempw) //empty ffc, nothing more to load
17079 2615 continue;
17080 1509 tempffc.data = tempw;
17081
17082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_getc(&(tempffc.cset),f))
17083 return qe_invalid;
17084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_igetw(&(tempffc.delay),f))
17085 return qe_invalid;
17086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_igetzf(&(tempffc.x),f))
17087 return qe_invalid;
17088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_igetzf(&(tempffc.y),f))
17089 return qe_invalid;
17090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_igetzf(&(tempffc.vx),f))
17091 return qe_invalid;
17092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_igetzf(&(tempffc.vy),f))
17093 return qe_invalid;
17094
1/2
✓ Branch 0 taken 1509 times.
✗ Branch 1 not taken.
1509 if(!p_igetzf(&(tempffc.ax),f))
17095 return qe_invalid;
17096
1/2
✓ Branch 0 taken 1509 times.
✗ Branch 1 not taken.
1509 if(!p_igetzf(&(tempffc.ay),f))
17097 return qe_invalid;
17098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_getc(&(tempffc.link),f))
17099 return qe_invalid;
17100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(version < 24)
17101 {
17102 if(!p_getc(&tempbyte,f))
17103 return qe_invalid;
17104 tempffc.hit_width = (tempbyte&0x3F)+1;
17105 tempffc.txsz = (tempbyte>>6)+1;
17106 if(!p_getc(&tempbyte,f))
17107 return qe_invalid;
17108 tempffc.hit_height = (tempbyte&0x3F)+1;
17109 tempffc.tysz = (tempbyte>>6)+1;
17110 }
17111 else
17112 {
17113
1/2
✓ Branch 0 taken 1509 times.
✗ Branch 1 not taken.
1509 if(!p_igetl(&(tempffc.hit_width),f))
17114 return qe_invalid;
17115
1/2
✓ Branch 0 taken 1509 times.
✗ Branch 1 not taken.
1509 if(!p_igetl(&(tempffc.hit_height),f))
17116 return qe_invalid;
17117
1/2
✓ Branch 0 taken 1509 times.
✗ Branch 1 not taken.
1509 if(!p_getc(&(tempffc.txsz),f))
17118 return qe_invalid;
17119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_getc(&(tempffc.tysz),f))
17120 return qe_invalid;
17121 }
17122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_igetl(&(tempffc.flags),f))
17123 return qe_invalid;
17124 1509 tempffc.updateSolid();
17125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_igetw(&(tempffc.script),f))
17126 return qe_invalid;
17127
2/2
✓ Branch 0 taken 12072 times.
✓ Branch 1 taken 1509 times.
13581 for(auto q = 0; q < 8; ++q)
17128 {
17129
1/2
✓ Branch 0 taken 12072 times.
✗ Branch 1 not taken.
12072 if(!p_igetl(&(tempffc.initd[q]),f))
17130 return qe_invalid;
17131 12072 }
17132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509 times.
1509 if(!p_getc(&(tempbyte),f))
17133 return qe_invalid;
17134 1509 tempffc.inita[0]=tempbyte*10000;
17135
17136
1/2
✓ Branch 0 taken 1509 times.
✗ Branch 1 not taken.
1509 if(!p_getc(&(tempbyte),f))
17137 return qe_invalid;
17138 1509 tempffc.inita[1]=tempbyte*10000;
17139
17140
1/2
✓ Branch 0 taken 1509 times.
✗ Branch 1 not taken.
1509 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17141 {
17142 tempffc.script = 0;
17143 for(int q = 0; q < 8; ++q)
17144 tempffc.initd[q] = 0;
17145 }
17146 1509 }
17147
2/2
✓ Branch 0 taken 225124 times.
✓ Branch 1 taken 1791 times.
226915 for(word m = numffc; m < MAXFFCS; ++m)
17148 {
17149 225124 temp_mapscr->ffcs[m].clear();
17150 225124 }
17151 //END FFC
17152 }
17153 248967 return 0;
17154 257648 }
17155
17156
17157 130 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17158 {
17159
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17160 130 int32_t scr=0;
17161
17162 130 word version=0;
17163 dword dummy;
17164 int32_t screens_to_read;
17165
17166 130 mapscr temp_mapscr;
17167 word temp_map_count;
17168 dword section_size;
17169
17170
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17171 {
17172 4 screens_to_read=MAPSCRS192b136;
17173 4 }
17174 else
17175 {
17176 126 screens_to_read=MAPSCRS;
17177 }
17178
17179
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version > 0x192)
17180 {
17181 //section version info
17182
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&version,f))
17183 {
17184 return qe_invalid;
17185 }
17186
17187 126 FFCore.quest_format[vMaps] = version;
17188
17189 //al_trace("Maps version %d\n", version);
17190
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&dummy,f))
17191 {
17192 return qe_invalid;
17193 }
17194
17195 //section size
17196
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetl(&section_size,f))
17197 {
17198 return qe_invalid;
17199 }
17200
17201 //finally... section data
17202
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&temp_map_count,f))
17203 {
17204 return 5;
17205 }
17206 126 }
17207 else
17208 {
17209 4 temp_map_count=map_count;
17210 }
17211
17212
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS))
17213 {
17214 return qe_invalid;
17215 }
17216
17217
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (!should_skip)
17218 {
17219 130 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17220
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 TheMaps.resize(_mapsSize);
17221 130 map_autolayers.clear();
17222
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 map_autolayers.resize(temp_map_count*6);
17223
2/2
✓ Branch 0 taken 258536 times.
✓ Branch 1 taken 130 times.
258666 for(int32_t i(0); i<_mapsSize; i++)
17224
1/2
✓ Branch 0 taken 258536 times.
✗ Branch 1 not taken.
258536 TheMaps[i].zero_memory();
17225 130 }
17226
17227
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 temp_mapscr.zero_memory();
17228
17229
4/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 1901 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 1901 times.
2031 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17230 {
17231 1901 byte valid=1;
17232
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1819 times.
1901 if(version > 22)
17233 {
17234
2/4
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
82 if(!p_getc(&valid,f))
17235 return qe_invalid;
17236 82 }
17237
4/4
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1838 times.
✓ Branch 3 taken 58 times.
1901 if(valid && version > 25)
17238 {
17239
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 58 times.
406 for(int q = 0; q < 6; ++q)
17240 {
17241
2/4
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 348 times.
✗ Branch 3 not taken.
348 if(!p_igetw(&map_autolayers[i*6+q],f))
17242 return qe_invalid;
17243 348 }
17244 58 }
17245
2/2
✓ Branch 0 taken 258328 times.
✓ Branch 1 taken 1901 times.
260229 for(int32_t j=0; j<screens_to_read; j++)
17246 {
17247 258328 scr=i*MAPSCRS+j;
17248
1/2
✓ Branch 0 taken 258328 times.
✗ Branch 1 not taken.
258328 clear_screen(&temp_mapscr);
17249
2/2
✓ Branch 0 taken 257648 times.
✓ Branch 1 taken 680 times.
258328 if(valid)
17250
1/2
✓ Branch 0 taken 257648 times.
✗ Branch 1 not taken.
257648 readmapscreen(f, Header, &temp_mapscr, version, scr);
17251
17252
1/2
✓ Branch 0 taken 258328 times.
✗ Branch 1 not taken.
258328 if (!should_skip)
17253
1/2
✓ Branch 0 taken 258328 times.
✗ Branch 1 not taken.
258328 TheMaps[scr] = temp_mapscr;
17254 258328 }
17255
17256
1/2
✓ Branch 0 taken 1901 times.
✗ Branch 1 not taken.
1901 if (should_skip)
17257 continue;
17258
17259
3/6
✓ Branch 0 taken 1849 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1849 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1901 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17260 {
17261 52 int32_t index = (i*MAPSCRS+132);
17262
17263
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 TheMaps[index]=TheMaps[index-1];
17264
17265 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17266 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17267 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17268
17269
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17270 {
17271 156 scr=i*MAPSCRS+j;
17272
17273
1/2
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
156 TheMaps[scr].zero_memory();
17274 156 TheMaps[scr].valid = mVERSION;
17275 156 TheMaps[scr].screen_midi = -1;
17276 156 TheMaps[scr].csensitive = 1;
17277 156 }
17278 52 }
17279
17280
3/6
✓ Branch 0 taken 1849 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1849 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1901 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17281 {
17282
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17283 {
17284 7072 scr=i*MAPSCRS+j;
17285 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17286
17287
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17288 {
17289
1/2
✓ Branch 0 taken 905216 times.
✗ Branch 1 not taken.
905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17290
1/2
✓ Branch 0 taken 905216 times.
✗ Branch 1 not taken.
905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17291
1/2
✓ Branch 0 taken 905216 times.
✗ Branch 1 not taken.
905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17292 905216 }
17293 7072 }
17294 52 }
17295 1901 }
17296 130 map_count = temp_map_count;
17297
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 clear_screen(&temp_mapscr);
17298 130 return 0;
17299 130 }
17300
17301
17302 1088537 void update_combo(newcombo& cmb, word section_version)
17303 {
17304
2/2
✓ Branch 0 taken 163968 times.
✓ Branch 1 taken 924569 times.
1088537 if(section_version < 40)
17305 {
17306
3/3
✓ Branch 0 taken 1358 times.
✓ Branch 1 taken 14128 times.
✓ Branch 2 taken 909083 times.
924569 switch(cmb.type)
17307 {
17308 case cWATER: case cSHALLOWWATER:
17309 14128 cmb.attribytes[6] = iwRipples;
17310 14128 break;
17311 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17312 1358 cmb.attribytes[6] = iwTallGrass;
17313 1358 break;
17314 }
17315 924569 }
17316 1088537 }
17317 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17318 {
17319
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17320
17321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if (!should_skip)
17322 {
17323 95 reset_combo_animations();
17324 95 reset_combo_animations2();
17325 95 init_combo_classes();
17326 95 }
17327
17328 // combos
17329 95 word combos_used=0;
17330 int32_t dummy;
17331 byte padding;
17332 95 newcombo temp_combo;
17333 //word section_cversion=0;
17334
17335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if (!should_skip)
17336
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17337
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201695 combobuf[q].clear();
17338
17339 // if(version > 0x192)
17340 // {
17341 // //section version info
17342 // if(!p_igetw(&section_version,f))
17343 // {
17344 // return qe_invalid;
17345 // }
17346
17347 // FFCore.quest_format[vCombos] = section_version;
17348
17349 // //al_trace("Combos version %d\n", section_version);
17350 // if(!p_igetw(&section_cversion,f))
17351 // {
17352 // return qe_invalid;
17353 // }
17354
17355 // //section size
17356 // if(!p_igetl(&dummy,f))
17357 // {
17358 // return qe_invalid;
17359 // }
17360 // }
17361
17362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17363 {
17364 combos_used=1024;
17365 }
17366
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17367 {
17368 4 combos_used=2048;
17369 4 }
17370 else
17371 {
17372
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17373 {
17374 return qe_invalid;
17375 }
17376 }
17377
17378 //finally... section data
17379
2/2
✓ Branch 0 taken 873209 times.
✓ Branch 1 taken 95 times.
873304 for(int32_t i=0; i<combos_used; i++)
17380 {
17381
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17382
17383
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17384 {
17385
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17386 {
17387 return qe_invalid;
17388 }
17389 68884 }
17390 else
17391 {
17392
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17393 {
17394 return qe_invalid;
17395 }
17396 }
17397 873209 temp_combo.o_tile = temp_combo.tile;
17398
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17399 {
17400 return qe_invalid;
17401 }
17402
17403
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17404 {
17405 return qe_invalid;
17406 }
17407
17408
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17409 {
17410 return qe_invalid;
17411 }
17412
17413
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17414 {
17415 return qe_invalid;
17416 }
17417
17418
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17419 {
17420
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17421 return qe_invalid;
17422
17423
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17424 return qe_invalid;
17425
17426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17427 {
17428
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17429 {
17430 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17431 {
17432 if(!p_getc(&padding,f))
17433 return qe_invalid;
17434 }
17435 }
17436 8192 }
17437 8192 }
17438
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17439 {
17440
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17441 return qe_invalid;
17442
17443
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17444 return qe_invalid;
17445
17446
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17447 return qe_invalid;
17448
17449
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17450 return qe_invalid;
17451
17452 //Base flag
17453
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17454
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17455 return qe_invalid;
17456
17457
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17458 {
17459
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17460 return qe_invalid;
17461
17462
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17463 return qe_invalid;
17464 399183 }
17465
17466
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17467
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17468 return qe_invalid;
17469
17470
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17471 {
17472
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17473 return qe_invalid;
17474
17475
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17476 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17477 399183 }
17478
17479
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17480 {
17481
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17482
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17483 return qe_invalid;
17484
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17485 return qe_invalid;
17486
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17487
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17488 return qe_invalid;
17489 68884 }
17490
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17491 {
17492
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17493
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17494 return qe_invalid;
17495 68884 }
17496
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17497 {
17498 for ( int32_t q = 0; q < 2; q++ )
17499 if(!p_igetl(&temp_combo.triggerflags[q],f))
17500 return qe_invalid;
17501 }
17502
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17503
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17504 return qe_invalid;
17505
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17506
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17507 return qe_invalid;
17508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17509 {
17510 if(!p_getc(&temp_combo.triggeritem,f))
17511 return qe_invalid;
17512 if(!p_getc(&temp_combo.trigtimer,f))
17513 return qe_invalid;
17514 }
17515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17516 if(!p_getc(&temp_combo.trigsfx,f))
17517 return qe_invalid;
17518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17519 if(!p_igetl(&temp_combo.trigchange,f))
17520 return qe_invalid;
17521
17522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17523 {
17524 if(!p_igetw(&temp_combo.trigprox,f))
17525 return qe_invalid;
17526 if(!p_getc(&temp_combo.trigctr,f))
17527 return qe_invalid;
17528 if(!p_igetl(&temp_combo.trigctramnt,f))
17529 return qe_invalid;
17530 }
17531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17532 if(!p_getc(&temp_combo.triglbeam,f))
17533 return qe_invalid;
17534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17535 {
17536 if(!p_getc(&temp_combo.trigcschange,f))
17537 return qe_invalid;
17538 if(!p_igetw(&temp_combo.spawnitem,f))
17539 return qe_invalid;
17540 if(!p_igetw(&temp_combo.spawnenemy,f))
17541 return qe_invalid;
17542 if(!p_getc(&temp_combo.exstate,f))
17543 return qe_invalid;
17544 if(!p_igetl(&temp_combo.spawnip,f))
17545 return qe_invalid;
17546 if(!p_getc(&temp_combo.trigcopycat,f))
17547 return qe_invalid;
17548 }
17549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17550 if(!p_getc(&temp_combo.trigcooldown,f))
17551 return qe_invalid;
17552
17553
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17554 {
17555 char label[12];
17556 68884 label[11] = '\0';
17557
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17558
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17559 return qe_invalid;
17560
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17561 68884 }
17562
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17563
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17564
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17565 68884 return qe_invalid;
17566 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17567 * This fixes a poor implementation of a ->next flag bug thing.
17568 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17569 * there was a version bump a few weeks before a change that broke stuff.
17570 */
17571
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17572 {
17573 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17574 }
17575 //combo scripts
17576
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17577 {
17578
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17579 return qe_invalid;
17580
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17581
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17582 return qe_invalid;
17583 68884 }
17584 //al_trace("Read combo script data\n");
17585
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17586 {
17587
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17588
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17589
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17590
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17591 68884 }
17592
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17593 {
17594
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17595
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17596 return qe_invalid;
17597
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17598
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17599 return qe_invalid;
17600 68884 }
17601
17602
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17603 for(int32_t q=0; q<11; q++)
17604 if(!p_getc(&dummy,f))
17605 return qe_invalid;
17606 865017 }
17607
17608 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17609
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17610 {
17611
2/2
✓ Branch 0 taken 465834 times.
✓ Branch 1 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17612 {
17613
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17614 {
17615 case 130:
17616 temp_combo.tile = 132;
17617 break;
17618
17619 case 131:
17620 temp_combo.tile = 133;
17621 break;
17622
17623 case 132:
17624 temp_combo.tile = 130;
17625 break;
17626
17627 case 133:
17628 temp_combo.tile = 131;
17629 break;
17630 }
17631 8192 }
17632 474026 }
17633
17634
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17635 804325 temp_combo.o_tile = temp_combo.tile;
17636
17637
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17638 804325 temp_combo.walk |= 0xF0;
17639
17640
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17641
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17642 4021625 temp_combo.attributes[q] *= 10000L;
17643
17644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17645 {
17646
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17647 {
17648 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17649 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17650 case cTRIGGERGENERIC: case cCSWITCH:
17651 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17652 384 }
17653 873209 }
17654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17655 {
17656
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17657 {
17658 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17660 3061 temp_combo.attribytes[3] = WAV_DOOR;
17661 3061 temp_combo.usrflags &= ~cflag3;
17662 3061 break;
17663 }
17664 873209 }
17665
17666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17667
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17668
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17669 temp_combo.usrflags |= cflag3;
17670
17671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17672 {
17673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17674 temp_combo.trigchange = 1;
17675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17676 temp_combo.trigchange = -1;
17677 873209 else temp_combo.trigchange = 0;
17678 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17679 873209 }
17680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17681 {
17682
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17683 {
17684 case cLOCKBLOCK: case cLOCKEDCHEST:
17685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17686 temp_combo.usrflags |= cflag8;
17687 1689 else temp_combo.usrflags &= ~cflag8;
17688 1689 temp_combo.usrflags &= ~cflag7;
17689 1689 break;
17690 }
17691
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
17692 {
17693 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17694 69 temp_combo.attrishorts[2] = -1;
17695 69 temp_combo.usrflags |= cflag7;
17696 69 break;
17697 }
17698 873209 }
17699
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
17700 {
17701 804325 temp_combo.genflags = 0;
17702
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
17703 {
17704 case cPUSH_WAIT: case cPUSH_HEAVY:
17705 case cPUSH_HW: case cL_STATUE:
17706 case cR_STATUE: case cPUSH_HEAVY2:
17707 case cPUSH_HW2: case cPOUND:
17708 case cC_STATUE: case cMIRROR:
17709 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17710 case cMAGICPRISM: case cMAGICPRISM4:
17711 case cMAGICSPONGE: case cEYEBALL_A:
17712 case cEYEBALL_B: case cEYEBALL_4:
17713 case cBUSH: case cFLOWERS:
17714 case cLOCKBLOCK: case cLOCKBLOCK2:
17715 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17716 case cCHEST: case cCHEST2:
17717 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17718 case cBOSSCHEST: case cBOSSCHEST2:
17719 case cBUSHNEXT: case cBUSHTOUCHY:
17720 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17721 case cSIGNPOST: case cCSWITCHBLOCK:
17722 case cTORCH: case cTRIGGERGENERIC:
17723
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
17724 {
17725 temp_combo.genflags |= cflag1;
17726 temp_combo.usrflags &= ~cflag16;
17727 }
17728 19291 break;
17729 }
17730 804325 }
17731
17732 873209 update_combo(temp_combo, section_version);
17733
17734
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(i>=start_combo && !should_skip)
17735 {
17736
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17737 {
17738 temp_combo.script = 0;
17739 for(int q = 0; q < 8; ++q)
17740 temp_combo.initd[q] = 0;
17741 }
17742
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
17743 873209 }
17744 873209 }
17745
17746
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if (should_skip)
17747 return 0;
17748
17749
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17750 {
17751
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17752 {
17753
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17754 {
17755 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17756 }
17757 261120 }
17758 4 }
17759
17760 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17761
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_editor())
17762 {
17763
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17764
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
17765 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17766 12 }
17767
17768
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
17769 {
17770
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17771 {
17772
6/9
✓ Branch 0 taken 1043840 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 45 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1044480 switch(combobuf[tmpcounter].type)
17773 {
17774 case cSLASH:
17775 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
17776 250 break;
17777
17778 case cSLASHITEM:
17779 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17780 174 break;
17781
17782 case cBUSH:
17783 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
17784 126 break;
17785
17786 case cFLOWERS:
17787 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17788 45 break;
17789
17790 case cTALLGRASS:
17791 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17792 45 break;
17793
17794 case cSLASHNEXT:
17795 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17796 break;
17797
17798 case cSLASHNEXTITEM:
17799 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17800 break;
17801
17802 case cBUSHNEXT:
17803 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17804 break;
17805 }
17806 1044480 }
17807 16 }
17808
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
17809 {
17810
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17811 {
17812
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
17813 {
17814 8054 combobuf[tmpcounter].attributes[0] = 40000L;
17815 8054 }
17816 6071040 }
17817 93 }
17818
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17819 {
17820 1 combobuf[0].walk = 0xF0;
17821 1 combobuf[0].type = 0;
17822 1 combobuf[0].flag = 0;
17823 1 }
17824
17825 //Now for the new combo alias reset
17826
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
17827 {
17828
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17829 {
17830 131072 combo_aliases[j].width = 0;
17831 131072 combo_aliases[j].height = 0;
17832 131072 combo_aliases[j].layermask = 0;
17833
17834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
17835 {
17836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 delete[] combo_aliases[j].combos;
17837 131072 }
17838
17839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
17840 {
17841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 delete[] combo_aliases[j].csets;
17842 131072 }
17843
17844
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
17845
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
17846 131072 combo_aliases[j].combos[0] = 0;
17847 131072 combo_aliases[j].csets[0] = 0;
17848 131072 }
17849 16 }
17850
17851
17852
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
17853
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
17854 95 return 0;
17855 95 }
17856 215328 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17857 {
17858 byte combo_has_flags;
17859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215328 times.
215328 if(!p_getc(&combo_has_flags,f))
17860 return qe_invalid;
17861
17862 215328 temp_combo.clear();
17863
2/2
✓ Branch 0 taken 147931 times.
✓ Branch 1 taken 67397 times.
215328 if(combo_has_flags)
17864 {
17865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67397 times.
67397 if(combo_has_flags&CHAS_BASIC)
17866 {
17867
1/2
✓ Branch 0 taken 67397 times.
✗ Branch 1 not taken.
67397 if(!p_igetl(&temp_combo.tile,f))
17868 {
17869 return qe_invalid;
17870 }
17871 67397 temp_combo.o_tile = temp_combo.tile;
17872
17873
1/2
✓ Branch 0 taken 67397 times.
✗ Branch 1 not taken.
67397 if(!p_getc(&temp_combo.flip,f))
17874 {
17875 return qe_invalid;
17876 }
17877
17878
1/2
✓ Branch 0 taken 67397 times.
✗ Branch 1 not taken.
67397 if(!p_getc(&temp_combo.walk,f))
17879 {
17880 return qe_invalid;
17881 }
17882
17883
1/2
✓ Branch 0 taken 67397 times.
✗ Branch 1 not taken.
67397 if(!p_getc(&temp_combo.type,f))
17884 {
17885 return qe_invalid;
17886 }
17887
17888
1/2
✓ Branch 0 taken 67397 times.
✗ Branch 1 not taken.
67397 if(!p_getc(&temp_combo.flag,f))
17889 {
17890 return qe_invalid;
17891 }
17892
17893
1/2
✓ Branch 0 taken 67397 times.
✗ Branch 1 not taken.
67397 if(!p_getc(&temp_combo.csets,f))
17894 {
17895 return qe_invalid;
17896 }
17897 67397 }
17898
2/2
✓ Branch 0 taken 67389 times.
✓ Branch 1 taken 8 times.
67397 if(combo_has_flags&CHAS_SCRIPT)
17899 {
17900
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (s_version>=41)
17901 {
17902 8 p_getcstr(&temp_combo.label, f);
17903 8 }
17904 else
17905 {
17906 char label[12];
17907 label[11] = '\0';
17908 for ( int32_t q = 0; q < 11; q++ )
17909 {
17910 if(!p_getc(&label[q],f))
17911 {
17912 return qe_invalid;
17913 }
17914 }
17915 temp_combo.label = label;
17916 }
17917
17918
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17919 8 auto initd_count = s_version >= 43 ? 8 : 2;
17920
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8 times.
72 for ( int32_t q = 0; q < initd_count; q++ )
17921 {
17922
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_igetl(&temp_combo.initd[q],f))
17923 {
17924 return qe_invalid;
17925 }
17926 64 }
17927 8 }
17928
2/2
✓ Branch 0 taken 51356 times.
✓ Branch 1 taken 16041 times.
67397 if(combo_has_flags&CHAS_ANIM)
17929 {
17930
1/2
✓ Branch 0 taken 16041 times.
✗ Branch 1 not taken.
16041 if(!p_getc(&temp_combo.frames,f))
17931 {
17932 return qe_invalid;
17933 }
17934
17935
1/2
✓ Branch 0 taken 16041 times.
✗ Branch 1 not taken.
16041 if(!p_getc(&temp_combo.speed,f))
17936 {
17937 return qe_invalid;
17938 }
17939
17940
1/2
✓ Branch 0 taken 16041 times.
✗ Branch 1 not taken.
16041 if(!p_igetw(&temp_combo.nextcombo,f))
17941 {
17942 return qe_invalid;
17943 }
17944
17945
1/2
✓ Branch 0 taken 16041 times.
✗ Branch 1 not taken.
16041 if(!p_getc(&temp_combo.nextcset,f))
17946 {
17947 return qe_invalid;
17948 }
17949
17950
1/2
✓ Branch 0 taken 16041 times.
✗ Branch 1 not taken.
16041 if(!p_getc(&temp_combo.skipanim,f))
17951 {
17952 return qe_invalid;
17953 }
17954
17955
1/2
✓ Branch 0 taken 16041 times.
✗ Branch 1 not taken.
16041 if(!p_getc(&temp_combo.skipanimy,f))
17956 {
17957 return qe_invalid;
17958 }
17959
17960
1/2
✓ Branch 0 taken 16041 times.
✗ Branch 1 not taken.
16041 if(!p_getc(&temp_combo.animflags,f))
17961 {
17962 return qe_invalid;
17963 }
17964 16041 }
17965
2/2
✓ Branch 0 taken 58174 times.
✓ Branch 1 taken 9223 times.
67397 if(combo_has_flags&CHAS_ATTRIB)
17966 {
17967
2/2
✓ Branch 0 taken 36892 times.
✓ Branch 1 taken 9223 times.
46115 for ( int32_t q = 0; q < 4; q++ )
17968 {
17969
1/2
✓ Branch 0 taken 36892 times.
✗ Branch 1 not taken.
36892 if(!p_igetl(&temp_combo.attributes[q],f))
17970 {
17971 return qe_invalid;
17972 }
17973 36892 }
17974
2/2
✓ Branch 0 taken 73784 times.
✓ Branch 1 taken 9223 times.
83007 for ( int32_t q = 0; q < 8; q++ )
17975 {
17976
1/2
✓ Branch 0 taken 73784 times.
✗ Branch 1 not taken.
73784 if(!p_getc(&temp_combo.attribytes[q],f))
17977 {
17978 return qe_invalid;
17979 }
17980 73784 }
17981
2/2
✓ Branch 0 taken 73784 times.
✓ Branch 1 taken 9223 times.
83007 for ( int32_t q = 0; q < 8; q++ )
17982 {
17983
1/2
✓ Branch 0 taken 73784 times.
✗ Branch 1 not taken.
73784 if(!p_igetw(&temp_combo.attrishorts[q],f))
17984 {
17985 return qe_invalid;
17986 }
17987 73784 }
17988 9223 }
17989
2/2
✓ Branch 0 taken 65191 times.
✓ Branch 1 taken 2206 times.
67397 if(combo_has_flags&CHAS_FLAG)
17990 {
17991
1/2
✓ Branch 0 taken 2206 times.
✗ Branch 1 not taken.
2206 if(!p_igetl(&temp_combo.usrflags,f))
17992 {
17993 return qe_invalid;
17994 }
17995
1/2
✓ Branch 0 taken 2206 times.
✗ Branch 1 not taken.
2206 if(!p_igetw(&temp_combo.genflags,f))
17996 {
17997 return qe_invalid;
17998 }
17999 2206 }
18000
2/2
✓ Branch 0 taken 66643 times.
✓ Branch 1 taken 754 times.
67397 if(combo_has_flags&CHAS_TRIG)
18001 {
18002 754 int numtrigs = s_version < 36 ? 3 : 6;
18003
2/2
✓ Branch 0 taken 4266 times.
✓ Branch 1 taken 754 times.
5020 for ( int32_t q = 0; q < numtrigs; q++ )
18004 {
18005
1/2
✓ Branch 0 taken 4266 times.
✗ Branch 1 not taken.
4266 if(!p_igetl(&temp_combo.triggerflags[q],f))
18006 {
18007 return qe_invalid;
18008 }
18009 4266 }
18010
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.triggerlevel,f))
18011 {
18012 return qe_invalid;
18013 }
18014
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.triggerbtn,f))
18015 {
18016 return qe_invalid;
18017 }
18018
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.triggeritem,f))
18019 {
18020 return qe_invalid;
18021 }
18022
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigtimer,f))
18023 {
18024 return qe_invalid;
18025 }
18026
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigsfx,f))
18027 {
18028 return qe_invalid;
18029 }
18030
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.trigchange,f))
18031 {
18032 return qe_invalid;
18033 }
18034
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.trigprox,f))
18035 {
18036 return qe_invalid;
18037 }
18038
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigctr,f))
18039 {
18040 return qe_invalid;
18041 }
18042
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.trigctramnt,f))
18043 {
18044 return qe_invalid;
18045 }
18046
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.triglbeam,f))
18047 {
18048 return qe_invalid;
18049 }
18050
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigcschange,f))
18051 {
18052 return qe_invalid;
18053 }
18054
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.spawnitem,f))
18055 {
18056 return qe_invalid;
18057 }
18058
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.spawnenemy,f))
18059 {
18060 return qe_invalid;
18061 }
18062
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.exstate,f))
18063 {
18064 return qe_invalid;
18065 }
18066
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetl(&temp_combo.spawnip,f))
18067 {
18068 return qe_invalid;
18069 }
18070
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigcopycat,f))
18071 {
18072 return qe_invalid;
18073 }
18074
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.trigcooldown,f))
18075 {
18076 return qe_invalid;
18077 }
18078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 754 times.
754 if(s_version >= 35)
18079 {
18080
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.prompt_cid,f))
18081 {
18082 return qe_invalid;
18083 }
18084
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_getc(&temp_combo.prompt_cs,f))
18085 {
18086 return qe_invalid;
18087 }
18088
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.prompt_x,f))
18089 {
18090 return qe_invalid;
18091 }
18092
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(!p_igetw(&temp_combo.prompt_y,f))
18093 {
18094 return qe_invalid;
18095 }
18096 754 }
18097
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 668 times.
754 if(s_version >= 36)
18098 {
18099
1/2
✓ Branch 0 taken 668 times.
✗ Branch 1 not taken.
668 if(!p_getc(&temp_combo.trig_lstate,f))
18100 {
18101 return qe_invalid;
18102 }
18103
1/2
✓ Branch 0 taken 668 times.
✗ Branch 1 not taken.
668 if(!p_getc(&temp_combo.trig_gstate,f))
18104 {
18105 return qe_invalid;
18106 }
18107
1/2
✓ Branch 0 taken 668 times.
✗ Branch 1 not taken.
668 if(!p_igetl(&temp_combo.trig_statetime,f))
18108 {
18109 return qe_invalid;
18110 }
18111 668 }
18112
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 668 times.
754 if(s_version >= 37)
18113 {
18114
1/2
✓ Branch 0 taken 668 times.
✗ Branch 1 not taken.
668 if(!p_igetw(&temp_combo.trig_genscr,f))
18115 {
18116 return qe_invalid;
18117 }
18118 668 }
18119
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 594 times.
754 if(s_version >= 38)
18120 {
18121
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_getc(&temp_combo.trig_group,f))
18122 {
18123 return qe_invalid;
18124 }
18125
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_igetw(&temp_combo.trig_group_val,f))
18126 {
18127 return qe_invalid;
18128 }
18129 594 }
18130 754 }
18131
2/2
✓ Branch 0 taken 67246 times.
✓ Branch 1 taken 151 times.
67397 if(combo_has_flags&CHAS_LIFT)
18132 {
18133
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_igetw(&temp_combo.liftcmb,f))
18134 return qe_invalid;
18135
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftcs,f))
18136 return qe_invalid;
18137
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_igetw(&temp_combo.liftundercmb,f))
18138 return qe_invalid;
18139
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftundercs,f))
18140 return qe_invalid;
18141
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftdmg,f))
18142 return qe_invalid;
18143
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftlvl,f))
18144 return qe_invalid;
18145
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftitm,f))
18146 return qe_invalid;
18147
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftflags,f))
18148 return qe_invalid;
18149
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftgfx,f))
18150 return qe_invalid;
18151
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftsprite,f))
18152 return qe_invalid;
18153
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftsfx,f))
18154 return qe_invalid;
18155
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18156 return qe_invalid;
18157
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftbreaksfx,f))
18158 return qe_invalid;
18159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(s_version >= 34)
18160 {
18161
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.lifthei,f))
18162 return qe_invalid;
18163
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.lifttime,f))
18164 return qe_invalid;
18165 151 }
18166
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 144 times.
151 if(s_version >= 39)
18167 {
18168
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&temp_combo.lift_parent_item,f))
18169 return qe_invalid;
18170 144 }
18171 151 }
18172
2/2
✓ Branch 0 taken 67297 times.
✓ Branch 1 taken 100 times.
67397 if(combo_has_flags&CHAS_GENERAL)
18173 {
18174
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.speed_mult,f))
18175 return qe_invalid;
18176
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.speed_div,f))
18177 return qe_invalid;
18178
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetzf(&temp_combo.speed_add,f))
18179 return qe_invalid;
18180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(s_version >= 42)
18181 {
18182
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_appear,f))
18183 return qe_invalid;
18184
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_disappear,f))
18185 return qe_invalid;
18186
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_loop,f))
18187 return qe_invalid;
18188
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_walking,f))
18189 return qe_invalid;
18190
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_standing,f))
18191 return qe_invalid;
18192
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.spr_appear,f))
18193 return qe_invalid;
18194
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.spr_disappear,f))
18195 return qe_invalid;
18196
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.spr_walking,f))
18197 return qe_invalid;
18198
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.spr_standing,f))
18199 return qe_invalid;
18200 100 }
18201
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(s_version >= 44)
18202 {
18203 if(!p_getc(&temp_combo.sfx_tap,f))
18204 return qe_invalid;
18205 }
18206 100 }
18207 67397 }
18208 215328 update_combo(temp_combo, s_version);
18209 215328 return 0;
18210 215328 }
18211 130 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18212 {
18213
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18214
18215 130 word section_version=0;
18216 130 word section_cversion=0;
18217 130 word combos_used=0;
18218 int32_t dummy;
18219 byte padding;
18220 130 newcombo temp_combo;
18221
18222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (!should_skip)
18223 {
18224
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 reset_combo_animations();
18225
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 reset_combo_animations2();
18226
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 init_combo_classes();
18227
18228
2/2
✓ Branch 0 taken 8486400 times.
✓ Branch 1 taken 130 times.
8486530 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18229
1/2
✓ Branch 0 taken 8486400 times.
✗ Branch 1 not taken.
8486400 combobuf[q].clear();
18230 130 }
18231
18232
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(version > 0x192) //Version info
18233 {
18234
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&section_version,f))
18235 {
18236 return qe_invalid;
18237 }
18238 126 FFCore.quest_format[vCombos] = section_version;
18239
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&section_cversion,f))
18240 {
18241 return qe_invalid;
18242 }
18243
18244 //section size
18245
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetl(&dummy,f))
18246 {
18247 return qe_invalid;
18248 }
18249 126 }
18250
18251
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 95 times.
130 if(section_version > 32) //Cleanup time!
18252 {
18253
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if(!p_igetw(&combos_used,f))
18254 {
18255 return qe_invalid;
18256 }
18257
2/2
✓ Branch 0 taken 215328 times.
✓ Branch 1 taken 35 times.
215363 for(int32_t i=0; i<combos_used; i++)
18258 {
18259
1/2
✓ Branch 0 taken 215328 times.
✗ Branch 1 not taken.
215328 auto ret = readcombo_loop(f,section_version,temp_combo);
18260
1/2
✓ Branch 0 taken 215328 times.
✗ Branch 1 not taken.
215328 if(ret) return ret;
18261
1/2
✓ Branch 0 taken 215328 times.
✗ Branch 1 not taken.
215328 if(i>=start_combo)
18262 {
18263
1/2
✓ Branch 0 taken 215328 times.
✗ Branch 1 not taken.
215328 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18264 {
18265 temp_combo.script = 0;
18266 for(int q = 0; q < 8; ++q)
18267 temp_combo.initd[q] = 0;
18268 }
18269
1/2
✓ Branch 0 taken 215328 times.
✗ Branch 1 not taken.
215328 combobuf[i] = temp_combo;
18270 215328 }
18271 215328 }
18272 35 }
18273 else //Call the old function for all old versions
18274 {
18275
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(ret) return ret; //error, end read
18277 }
18278
18279
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (should_skip)
18280 return 0;
18281
18282
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 34 times.
130 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18283 {
18284 34 combobuf[0].walk = 0xF0;
18285 34 combobuf[0].type = 0;
18286 34 combobuf[0].flag = 0;
18287 34 }
18288
18289
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 setup_combo_animations();
18290
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 setup_combo_animations2();
18291 130 return 0;
18292 130 }
18293
18294 114 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18295 {
18296 //these are here to bypass compiler warnings about unused arguments
18297 114 Header=Header;
18298 114 version=version;
18299 114 build=build;
18300
18301 int32_t dummy;
18302 114 word sversion=0, c_sversion;
18303
18304 //section version info
18305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetw(&sversion,f))
18306 {
18307 return qe_invalid;
18308 }
18309
18310 114 FFCore.quest_format[vComboAliases] = sversion;
18311
18312 //al_trace("Combo aliases version %d\n", sversion);
18313
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&c_sversion,f))
18314 {
18315 return qe_invalid;
18316 }
18317
18318 //section size
18319
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy,f))
18320 {
18321 return qe_invalid;
18322 }
18323
18324 114 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18325
18326
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
114 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18327 {
18328 77 max_num_combo_aliases = MAX250COMBOALIASES;
18329 77 }
18330
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18331 {
18332 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18333 }
18334
18335
2/2
✓ Branch 0 taken 460800 times.
✓ Branch 1 taken 114 times.
460914 for(int32_t j=0; j<max_num_combo_aliases; j++)
18336 {
18337 byte width,height,mask,tempcset;
18338 int32_t count;
18339 word tempword;
18340 byte tempbyte;
18341
18342
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_igetw(&tempword,f))
18343 {
18344 return qe_invalid;
18345 }
18346
18347 460800 combo_aliases[j].combo = tempword;
18348
18349
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_getc(&tempbyte,f))
18350 {
18351 return qe_invalid;
18352 }
18353
18354 460800 combo_aliases[j].cset = tempbyte;
18355
18356
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_getc(&width,f))
18357 {
18358 return qe_invalid;
18359 }
18360
18361
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_getc(&height,f))
18362 {
18363 return qe_invalid;
18364 }
18365
18366
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 if(!p_getc(&mask,f))
18367 {
18368 return qe_invalid;
18369 }
18370
18371 460800 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18372
18373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460800 times.
460800 if(combo_aliases[j].combos != NULL)
18374 {
18375
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 delete[] combo_aliases[j].combos;
18376 460800 }
18377
18378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460800 times.
460800 if(combo_aliases[j].csets != NULL)
18379 {
18380
1/2
✓ Branch 0 taken 460800 times.
✗ Branch 1 not taken.
460800 delete[] combo_aliases[j].csets;
18381 460800 }
18382
18383 460800 combo_aliases[j].width = width;
18384 460800 combo_aliases[j].height = height;
18385 460800 combo_aliases[j].layermask = mask;
18386 460800 combo_aliases[j].combos = new word[count];
18387 460800 combo_aliases[j].csets = new byte[count];
18388
18389
2/2
✓ Branch 0 taken 472397 times.
✓ Branch 1 taken 460800 times.
933197 for(int32_t k=0; k<count; k++)
18390 {
18391
1/2
✓ Branch 0 taken 472397 times.
✗ Branch 1 not taken.
472397 if(!p_igetw(&tempword,f))
18392 {
18393 return qe_invalid;
18394 }
18395
18396 472397 combo_aliases[j].combos[k] = tempword;
18397 472397 }
18398
18399
2/2
✓ Branch 0 taken 472397 times.
✓ Branch 1 taken 460800 times.
933197 for(int32_t k=0; k<count; k++)
18400 {
18401
1/2
✓ Branch 0 taken 472397 times.
✗ Branch 1 not taken.
472397 if(!p_getc(&tempcset,f))
18402 {
18403 return qe_invalid;
18404 }
18405
18406 472397 combo_aliases[j].csets[k] = tempcset;
18407 472397 }
18408 460800 }
18409
18410 //Combo pools!
18411 114 word num_combo_pools = 0;
18412
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 35 times.
114 if(sversion >= 4)
18413 {
18414
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!p_igetw(&num_combo_pools,f))
18415 {
18416 return qe_invalid;
18417 }
18418 35 }
18419
18420
2/2
✓ Branch 0 taken 933888 times.
✓ Branch 1 taken 114 times.
934002 for(combo_pool& pool : combo_pools)
18421 {
18422 933888 pool.clear();
18423 }
18424
18425 114 combo_pool temp_cpool;
18426
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 114 times.
213 for(word cp = 0; cp < num_combo_pools; ++cp)
18427 {
18428 99 int32_t num_combos_in_pool = 0;
18429
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetl(&num_combos_in_pool,f))
18430 {
18431 return qe_invalid;
18432 }
18433
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(num_combos_in_pool < 1) continue; //nothing to read
18434
18435
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 temp_cpool.clear();
18436
18437 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18438
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 429 times.
528 for(auto q = 0; q < num_combos_in_pool; ++q)
18439 {
18440
2/4
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 429 times.
✗ Branch 3 not taken.
429 if(!p_igetl(&cp_cid,f))
18441 {
18442 return qe_invalid;
18443 }
18444
2/4
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 429 times.
✗ Branch 3 not taken.
429 if(!p_getc(&cp_cs,f))
18445 {
18446 return qe_invalid;
18447 }
18448
2/4
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 429 times.
✗ Branch 3 not taken.
429 if(!p_igetw(&cp_quant,f))
18449 {
18450 return qe_invalid;
18451 }
18452
1/2
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
429 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18453 429 }
18454
18455
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 combo_pools[cp] = temp_cpool;
18456 99 }
18457
18458 //Autocombos!
18459 114 word num_combo_autos = 0;
18460
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if (sversion >= 5)
18461 {
18462
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if (!p_igetw(&num_combo_autos, f))
18463 {
18464 return qe_invalid;
18465 }
18466 29 }
18467
18468
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 933888 times.
934002 for (combo_auto& cauto : combo_autos)
18469 {
18470
1/2
✓ Branch 0 taken 933888 times.
✗ Branch 1 not taken.
933888 cauto.clear(true);
18471 }
18472
18473
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 combo_auto temp_cauto;
18474
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 114 times.
138 for (word ca = 0; ca < num_combo_autos; ++ca)
18475 {
18476 byte type;
18477 int32_t display_cid, erase_cid;
18478 byte flags, arg;
18479
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_getc(&type, f))
18480 {
18481 return qe_invalid;
18482 }
18483
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_igetl(&display_cid, f))
18484 {
18485 return qe_invalid;
18486 }
18487
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_igetl(&erase_cid, f))
18488 {
18489 return qe_invalid;
18490 }
18491
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_getc(&flags, f))
18492 {
18493 return qe_invalid;
18494 }
18495
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_getc(&arg, f))
18496 {
18497 return qe_invalid;
18498 }
18499 24 int32_t num_combos_in_cauto = 0;
18500
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_igetl(&num_combos_in_cauto, f))
18501 {
18502 return qe_invalid;
18503 }
18504
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (num_combos_in_cauto < 1) continue; //nothing to read
18505
18506
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.clear();
18507
18508
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setType(type);
18509
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setDisplay(display_cid);
18510
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setEraseCombo(erase_cid);
18511
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setFlags(flags);
18512
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setArg(arg);
18513
18514 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18515
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 304 times.
328 for (auto q = 0; q < num_combos_in_cauto; ++q)
18516 {
18517
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
304 if (!p_getc(&ca_ctype, f))
18518 {
18519 return qe_invalid;
18520 }
18521
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
304 if (!p_igetl(&ca_cid, f))
18522 {
18523 return qe_invalid;
18524 }
18525
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18526 304 }
18527
18528
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 combo_autos[ca] = temp_cauto;
18529 24 }
18530
18531 114 return 0;
18532 114 }
18533
18534 130 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18535 {
18536
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18537
18538 //these are here to bypass compiler warnings about unused arguments
18539 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18540 //Capitalized cause it'll save you a headache. -Deedee
18541 130 start_cset=start_cset;
18542 130 max_csets=max_csets;
18543 130 word s_version=0;
18544
18545 miscQdata temp_misc;
18546 130 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18547
18548 byte temp_colordata[48];
18549 char temp_palname[PALNAMESIZE+1];
18550
18551 int32_t dummy;
18552 word palcycles;
18553
18554
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(version > 0x192)
18555 {
18556 //section version info
18557
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
18558 {
18559 return qe_invalid;
18560 }
18561
18562 126 FFCore.quest_format[vCSets] = s_version;
18563
18564 //al_trace("Color data version %d\n", s_version);
18565
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy,f))
18566 {
18567 return qe_invalid;
18568 }
18569
18570 //section size
18571
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
18572 {
18573 return qe_invalid;
18574 }
18575 126 }
18576
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
130 if (s_version < 5)
18577 {
18578
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18579
18580 //finally... section data
18581 93 int32_t q = 0;
18582 93 int32_t p = -15;
18583
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18584 {
18585 22320 memset(temp_colordata, 0, 48);
18586
18587
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18588 {
18589 return qe_invalid;
18590 }
18591
18592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22320 times.
22320 if (should_skip)
18593 continue;
18594
18595 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18596
18597 22320 ++q;
18598
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18599 {
18600
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18601 {
18602 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18603 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18604 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18605 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18606 1573 q+=4;
18607 1573 }
18608 else
18609 {
18610 for(int m = 0; m < 4; ++m)
18611 {
18612 memset(temp_colordata, 0, 48);
18613 if(!pfread(temp_colordata,48,f))
18614 {
18615 return qe_invalid;
18616 }
18617 memcpy(&colordata[q*48], temp_colordata, 48);
18618 ++q;
18619 }
18620 }
18621 1573 }
18622 22320 ++p;
18623 22320 }
18624
18625
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18626 {
18627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!should_skip)
18628 {
18629 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18630 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18631 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18632 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18633 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18634 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18635 4 }
18636 4 }
18637 else
18638 {
18639 89 memset(temp_colordata, 0, 48);
18640
18641
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18642 {
18643
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18644 {
18645 return qe_invalid;
18646 }
18647
18648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278837 times.
278837 if (should_skip)
18649 continue;
18650
18651 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18652
18653 278837 ++q;
18654
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18655 {
18656
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18657 {
18658 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18659 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18660 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18661 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18662 21425 q+=4;
18663 21425 }
18664 else
18665 {
18666 for(int m = 0; m < 4; ++m)
18667 {
18668 memset(temp_colordata, 0, 48);
18669 if(!pfread(temp_colordata,48,f))
18670 {
18671 return qe_invalid;
18672 }
18673 memcpy(&colordata[q*48], temp_colordata, 48);
18674 ++q;
18675 }
18676 }
18677 21425 }
18678 278837 ++p;
18679 278837 }
18680
18681
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18682 {
18683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!should_skip)
18684 {
18685 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18686 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18687 12 }
18688 12 }
18689 else
18690 {
18691
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18692 {
18693
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18694 {
18695 return qe_invalid;
18696 }
18697
18698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256256 times.
256256 if (should_skip)
18699 continue;
18700
18701 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18702 256256 ++q;
18703
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18704 {
18705
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18706 {
18707 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18708 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18709 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18710 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18711 19558 q+=4;
18712 19558 }
18713 else
18714 {
18715 for(int m = 0; m < 4; ++m)
18716 {
18717 memset(temp_colordata, 0, 48);
18718 if(!pfread(temp_colordata,48,f))
18719 {
18720 return qe_invalid;
18721 }
18722 memcpy(&colordata[q*48], temp_colordata, 48);
18723 ++q;
18724 }
18725 }
18726 19558 }
18727 256256 ++p;
18728 256256 }
18729
18730 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18731 }
18732 }
18733 93 }
18734 else
18735 {
18736
2/2
✓ Branch 0 taken 323713 times.
✓ Branch 1 taken 37 times.
323750 for(int32_t i=0; i<pdTOTAL255; ++i)
18737 {
18738 323713 memset(temp_colordata, 0, 48);
18739
18740
1/2
✓ Branch 0 taken 323713 times.
✗ Branch 1 not taken.
323713 if(!pfread(temp_colordata,48,f))
18741 {
18742 return qe_invalid;
18743 }
18744
18745 323713 memcpy(&colordata[i*48], temp_colordata, 48);
18746 323713 }
18747 }
18748
18749
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((version < 0x192)||((version == 0x192)&&(build<76)))
18750 {
18751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!should_skip)
18752 4 init_palnames();
18753 4 }
18754 else
18755 {
18756 126 int32_t palnamestoread = 0;
18757
18758
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114 times.
126 if(s_version < 3)
18759 12 palnamestoread = OLDMAXLEVELS;
18760 else
18761 114 palnamestoread = 512;
18762
18763
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 126 times.
61566 for(int32_t i=0; i<palnamestoread; ++i)
18764 {
18765
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18766 {
18767 return qe_invalid;
18768 }
18769
18770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61440 times.
61440 if (!should_skip)
18771 61440 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18772 61440 }
18773
18774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (should_skip)
18775 return 0;
18776
18777
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 126 times.
3198 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18778 {
18779 3072 memset(palnames[i], 0, PALNAMESIZE);
18780 3072 }
18781 }
18782
18783
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(version > 0x192)
18784 {
18785
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 126 times.
32382 for(int32_t i=0; i<256; i++)
18786 {
18787
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 32256 times.
129024 for(int32_t j=0; j<3; j++)
18788 {
18789 96768 temp_misc.cycles[i][j].first=0;
18790 96768 temp_misc.cycles[i][j].count=0;
18791 96768 temp_misc.cycles[i][j].speed=0;
18792 96768 }
18793 32256 }
18794
18795
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&palcycles,f))
18796 {
18797 return qe_invalid;
18798 }
18799
18800
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18801 {
18802 return qe_invalid;
18803 }
18804
18805
2/2
✓ Branch 0 taken 3560 times.
✓ Branch 1 taken 126 times.
3686 for(int32_t i=0; i<palcycles; i++)
18806 {
18807
2/2
✓ Branch 0 taken 10680 times.
✓ Branch 1 taken 3560 times.
14240 for(int32_t j=0; j<3; j++)
18808 {
18809
1/2
✓ Branch 0 taken 10680 times.
✗ Branch 1 not taken.
10680 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18810 {
18811 return qe_invalid;
18812 }
18813 10680 }
18814
18815
2/2
✓ Branch 0 taken 10680 times.
✓ Branch 1 taken 3560 times.
14240 for(int32_t j=0; j<3; j++)
18816 {
18817
1/2
✓ Branch 0 taken 10680 times.
✗ Branch 1 not taken.
10680 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18818 {
18819 return qe_invalid;
18820 }
18821 10680 }
18822
18823
2/2
✓ Branch 0 taken 10680 times.
✓ Branch 1 taken 3560 times.
14240 for(int32_t j=0; j<3; j++)
18824 {
18825
1/2
✓ Branch 0 taken 10680 times.
✗ Branch 1 not taken.
10680 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18826 {
18827 return qe_invalid;
18828 }
18829 10680 }
18830 3560 }
18831
18832 126 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18833 126 }
18834
18835 130 return 0;
18836 130 }
18837
18838 130 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18839 {
18840
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18841
18842 130 int32_t tiles_used=0;
18843 130 word section_version = 0;
18844 130 word section_cversion = 0;
18845 130 int32_t section_size= 0;
18846 130 byte *temp_tile = new byte[tilesize(tf32Bit)];
18847
18848 //Tile Expansion
18849 //if ( version >= 0x254 && build >= 41 )
18850
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
130 if (version < 0x254 && build < 41)
18851 {
18852 //al_trace("Build was < 41 when reading tiles\n");
18853 93 max_tiles = ZC250MAXTILES;
18854 93 }
18855
18856 //al_trace("Max Tiles: %d\n", max_tiles);
18857
18858
2/6
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18859 {
18860 if(!init_tiles(true, Header))
18861 {
18862 al_trace("Unable to initialize tiles\n");
18863 }
18864
18865 delete[] temp_tile;
18866 temp_tile=NULL;
18867 return 0;
18868 }
18869 else
18870 {
18871
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(version > 0x192)
18872 {
18873 //section version info
18874
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&section_version,f))
18875 {
18876 delete[] temp_tile;
18877 return qe_invalid;
18878 }
18879
18880 126 FFCore.quest_format[vTiles] = section_version;
18881
18882
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&section_cversion,f))
18883 {
18884 delete[] temp_tile;
18885 return qe_invalid;
18886 }
18887
18888 //section size
18889
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&section_size,f))
18890 {
18891 delete[] temp_tile;
18892 return qe_invalid;
18893 }
18894 126 }
18895
18896 //if ( build < 41 )
18897 //{
18898 // tiles_used = ZC250MAXTILES;
18899 //}
18900
18901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(version < 0x174)
18902 {
18903 tiles_used=TILES_PER_PAGE*4;
18904 } //no expanded tile space
18905
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 else if(version < 0x191)
18906 {
18907 4 tiles_used=OLDMAXTILES;
18908 4 }
18909 else
18910 {
18911 //finally... section data
18912
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
126 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18913 {
18914
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 if(!p_igetl(&tiles_used,f))
18915 {
18916 delete[] temp_tile;
18917 return qe_invalid;
18918 }
18919 37 }
18920 else
18921 {
18922
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
18923 {
18924 delete[] temp_tile;
18925 return qe_invalid;
18926 }
18927 }
18928 }
18929
18930
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 tiles_used=zc_min(tiles_used, max_tiles);
18931
18932 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18933 //if ( version < 0x254 && build < 41 )
18934
3/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if ( version < 0x254 || (version == 0x254 && build < 41) )
18935 //if ( build < 41 )
18936 {
18937
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18938 93 }
18939 else //2.55
18940 {
18941
1/2
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
37 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18942 }
18943
18944 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18945
18946 //al_trace("tiles_used = %d\n", tiles_used);
18947
18948
2/2
✓ Branch 0 taken 3524982 times.
✓ Branch 1 taken 130 times.
3525112 for(int32_t i=0; i<tiles_used; ++i)
18949 {
18950 3524982 byte format=tf4Bit;
18951 3524982 memset(temp_tile, 0, tilesize(tf32Bit));
18952
18953
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2894202 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3524982 if((version>0x211)||((version==0x211)&&(build>4)))
18954 {
18955
1/2
✓ Branch 0 taken 2894202 times.
✗ Branch 1 not taken.
2894202 if(!p_getc(&format,f))
18956 {
18957 delete[] temp_tile;
18958 return qe_invalid;
18959 }
18960 2894202 }
18961
4/4
✓ Branch 0 taken 1344648 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 616695 times.
✓ Branch 3 taken 727953 times.
3524982 if(section_version > 2 && !format)
18962 {
18963 727953 reset_tile(buf,start_tile+i,tf4Bit);
18964 727953 continue;
18965 }
18966
18967
2/2
✓ Branch 0 taken 2753154 times.
✓ Branch 1 taken 43875 times.
2797029 int size = format == tf4Bit ? 128 : tilesize(format);
18968
1/2
✓ Branch 0 taken 2797029 times.
✗ Branch 1 not taken.
2797029 if(!pfread(temp_tile,size,f))
18969 {
18970 delete[] temp_tile;
18971 return qe_invalid;
18972 }
18973
18974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2797029 times.
2797029 if (should_skip)
18975 continue;
18976
18977 2797029 buf[start_tile+i].format=format;
18978
18979
1/2
✓ Branch 0 taken 2797029 times.
✗ Branch 1 not taken.
2797029 if(buf[start_tile+i].data)
18980 {
18981 2797029 free(buf[start_tile+i].data);
18982 2797029 buf[start_tile+i].data=NULL;
18983 2797029 }
18984
18985 2797029 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
18986
18987
2/2
✓ Branch 0 taken 2753154 times.
✓ Branch 1 taken 43875 times.
2797029 if (format == tf4Bit)
18988 {
18989 byte temp[256];
18990 2753154 byte *si = temp_tile + 128;
18991 2753154 byte *di = temp + 256;
18992
18993
2/2
✓ Branch 0 taken 352403712 times.
✓ Branch 1 taken 2753154 times.
355156866 for(int i=127; i>=0; --i)
18994 {
18995 352403712 (*(--di)) = (*(--si)) >> 4;
18996 352403712 (*(--di)) = (*si) & 15;
18997 352403712 }
18998
18999 2753154 memcpy(buf[start_tile+i].data,temp,256);
19000 2753154 }
19001 else
19002 {
19003 43875 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19004 }
19005 2797029 }
19006 }
19007
19008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (should_skip)
19009 return 0;
19010
19011
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
130 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19012 {
19013 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19014
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19015 {
19016
19017 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19018 13855140 reset_tile(buf,q,tf4Bit);
19019
19020
19021 /*
19022
19023 byte tempbyte;
19024 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19025 {
19026 tempbyte=buf[ZC250MAXTILES-1].data[i];
19027 buf[q].data[i] = tempbyte;
19028 }
19029 //int32_t temp = tempbyte=buf[130].data[i];
19030 //buf[q].data = buf[ZC250MAXTILES-1].data;
19031 */
19032 //reset_tile(buf,q,tf4Bit);
19033 13855140 }
19034
19035 93 }
19036
19037
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37 times.
130 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19038 {
19039
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19040 {
19041 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19042 4121646 reset_tile(buf,i,tf4Bit);
19043 4121646 }
19044 93 }
19045 else
19046 {
19047
2/2
✓ Branch 0 taken 6383232 times.
✓ Branch 1 taken 37 times.
6383269 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19048 {
19049 //al_trace("Resetting tiles for build 41+\n");
19050 6383232 reset_tile(buf,i,tf4Bit);
19051 6383232 }
19052 }
19053
19054
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19055 {
19056
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
19057 {
19058 byte tempbyte;
19059 int32_t floattile=wpnsbuf[iwSwim].tile;
19060
19061 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19062 {
19063 tempbyte=buf[23].data[i];
19064 buf[23].data[i]=buf[24].data[i];
19065 buf[24].data[i]=buf[25].data[i];
19066 buf[25].data[i]=buf[26].data[i];
19067 buf[26].data[i]=tempbyte;
19068 }
19069 //swim tiles are out of order, too, but nobody cared? -Z
19070 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19071 {
19072 tempbyte=buf[floattile+11].data[i];
19073 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19074 buf[floattile+12].data[i]=tempbyte;
19075 }
19076 }
19077 4 }
19078
19079
3/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19080 {
19081
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
19082 {
19083 byte tempbyte;
19084
19085
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19086 {
19087 1024 tempbyte=buf[130].data[i];
19088 1024 buf[130].data[i]=buf[132].data[i];
19089 1024 buf[132].data[i]=tempbyte;
19090
19091 1024 tempbyte=buf[131].data[i];
19092 1024 buf[131].data[i]=buf[133].data[i];
19093 1024 buf[133].data[i]=tempbyte;
19094 1024 }
19095 4 }
19096 16 }
19097
19098 130 al_trace("Registering blank tiles\n");
19099 130 register_blank_tiles();
19100
19101 //memset(temp_tile, 0, tilesize(tf32Bit));
19102
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 delete[] temp_tile;
19103 130 temp_tile=NULL;
19104 130 return 0;
19105 130 }
19106
19107 130 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19108 {
19109
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19110
19111 static byte fake_midi_flags[32];
19112
19113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19114 int32_t dummy;
19115 word dummy2;
19116 // zcmidi_ temp_midi;
19117 int32_t tunes_to_read;
19118 130 int32_t tune_count=0;
19119 130 word section_version=0;
19120 130 zctune temp;
19121
19122
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version < 0x193)
19123 {
19124 // mf=Header->data_flags+ZQ_MIDIS2;
19125
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19126 {
19127 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19128 4 }
19129 else
19130 {
19131 tunes_to_read=MAXCUSTOMTUNES;
19132 }
19133 4 }
19134 else
19135 {
19136 //section version info
19137
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&section_version,f))
19138 {
19139 return qe_invalid;
19140 }
19141
19142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (!should_skip)
19143 126 FFCore.quest_format[vMIDIs] = section_version;
19144
19145 //al_trace("Tunes version %d\n", section_version);
19146
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy2,f))
19147 {
19148 return qe_invalid;
19149 }
19150
19151 //section size
19152
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
19153 {
19154 return qe_invalid;
19155 }
19156
19157 //finally... section data
19158
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!pfread(midi_flags,sizeof(midi_flags),f))
19159 {
19160 return qe_invalid;
19161 }
19162
19163 126 tunes_to_read=MAXCUSTOMTUNES;
19164 }
19165
19166
2/2
✓ Branch 0 taken 32760 times.
✓ Branch 1 taken 130 times.
32890 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19167 {
19168
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 30465 times.
32760 if(get_bit(mf, i))
19169 {
19170 2295 ++tune_count;
19171 2295 }
19172 32760 }
19173
19174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (!should_skip)
19175 130 reset_tunes(tunes); //reset_midis(midis);
19176
19177
2/2
✓ Branch 0 taken 31880 times.
✓ Branch 1 taken 130 times.
32010 for(int32_t i=0; i<tunes_to_read; i++)
19178 {
19179 31880 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19180
19181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31880 times.
31880 if (!should_skip)
19182 31880 tunes[i].reset(); // reset_midi(midis+i);
19183
19184
2/2
✓ Branch 0 taken 29585 times.
✓ Branch 1 taken 2295 times.
31880 if(get_bit(mf,i))
19185 {
19186
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1578 times.
2295 if(section_version < 4)
19187 {
19188
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!p_getstr(temp.title,20,f))
19189 {
19190 return qe_invalid;
19191 }
19192 717 }
19193 else
19194 {
19195
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19196 {
19197 return qe_invalid;
19198 }
19199 }
19200
19201
1/2
✓ Branch 0 taken 2295 times.
✗ Branch 1 not taken.
2295 if(!p_igetl(&temp.start,f))
19202 {
19203 return qe_invalid;
19204 }
19205
19206
1/2
✓ Branch 0 taken 2295 times.
✗ Branch 1 not taken.
2295 if(!p_igetl(&temp.loop_start,f))
19207 {
19208 return qe_invalid;
19209 }
19210
19211
1/2
✓ Branch 0 taken 2295 times.
✗ Branch 1 not taken.
2295 if(!p_igetl(&temp.loop_end,f))
19212 {
19213 return qe_invalid;
19214 }
19215
19216
1/2
✓ Branch 0 taken 2295 times.
✗ Branch 1 not taken.
2295 if(!p_igetw(&temp.loop,f))
19217 {
19218 return qe_invalid;
19219 }
19220
19221
1/2
✓ Branch 0 taken 2295 times.
✗ Branch 1 not taken.
2295 if(!p_igetw(&temp.volume,f))
19222 {
19223 return qe_invalid;
19224 }
19225
19226
2/2
✓ Branch 0 taken 2217 times.
✓ Branch 1 taken 78 times.
2295 if(Header->zelda_version < 0x193)
19227 {
19228
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19229 {
19230 return qe_invalid;
19231 }
19232 78 }
19233
19234
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1578 times.
2295 if(section_version >= 3)
19235 {
19236
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19237 {
19238 return qe_invalid;
19239 }
19240 1578 }
19241
19242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2295 times.
2295 if (!should_skip)
19243 2295 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19244
19245
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1578 times.
2295 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19246 {
19247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
717 if (should_skip)
19248 {
19249 if (read_midi(f)==NULL)
19250 {
19251 return qe_invalid;
19252 }
19253
19254 continue;
19255 }
19256
19257 // old format - a midi is a midi
19258
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19259 {
19260 return qe_invalid;
19261 }
19262
19263 //yes you can do this. Isn't the ? operator awesome? :)
19264 717 tunes[i].format = MFORMAT_MIDI;
19265 717 }
19266 else
19267 {
19268 // 'midi' could be midi or nes, gb, ... music
19269
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19270 {
19271 return qe_invalid;
19272 }
19273
19274 1578 zctune *ptr = &tunes[i];
19275
19276
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 switch(temp.format)
19277 {
19278 case MFORMAT_MIDI:
19279
1/2
✓ Branch 0 taken 1578 times.
✗ Branch 1 not taken.
1578 if((ptr->data=read_midi(f))==NULL)
19280 {
19281 return qe_invalid;
19282 }
19283
19284 1578 break;
19285
19286 default:
19287 return qe_invalid;
19288 break;
19289 }
19290 }
19291 2295 }
19292 31880 }
19293
19294 130 return 0;
19295 130 }
19296
19297 130 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19298 {
19299
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19300
19301 int32_t dummy;
19302 ZCHEATS tempzcheats;
19303 130 char temp_use_cheats=1;
19304 130 memset(&tempzcheats, 0, sizeof(tempzcheats));
19305 130 word s_version = 0;
19306
19307
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 126 times.
130 if(Header->zelda_version > 0x192)
19308 {
19309 //section version info
19310
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&s_version,f))
19311 {
19312 return qe_invalid;
19313 }
19314
19315 126 FFCore.quest_format[vCheats] = s_version;
19316 //al_trace("Cheats version %d\n", dummy);
19317
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&dummy,f))
19318 {
19319 return qe_invalid;
19320 }
19321
19322 //section size
19323
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetl(&dummy,f))
19324 {
19325 return qe_invalid;
19326 }
19327
19328 //finally... section data
19329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!p_getc(&temp_use_cheats,f))
19330 {
19331 return qe_invalid;
19332 }
19333 126 }
19334
19335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(Header->data_flags[ZQ_CHEATS2])
19336 {
19337
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(!p_igetl(&tempzcheats.flags,f))
19338 {
19339 return qe_invalid;
19340 }
19341
19342
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19343 {
19344 return qe_invalid;
19345 }
19346 130 }
19347
19348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (should_skip)
19349 return 0;
19350
19351 130 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19352 130 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19353
19354 130 return 0;
19355 130 }
19356
19357 101 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, word s_cversion, zinitdata& temp_zinit)
19358 {
19359
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 97 times.
101 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19360
19361 int32_t dummy;
19362 byte padding, tempbyte;
19363
19364 // Legacy item properties (now integrated into itemdata)
19365 byte sword_hearts[4];
19366 byte beam_hearts[4];
19367 101 byte beam_percent=0;
19368 word beam_power[4];
19369 101 byte hookshot_length=99;
19370 101 byte hookshot_links=100;
19371 101 byte longshot_length=99;
19372 101 byte longshot_links=100;
19373 101 byte moving_fairy_hearts=3;
19374 101 byte moving_fairy_heart_percent=0;
19375 101 byte stationary_fairy_hearts=3;
19376 101 byte stationary_fairy_heart_percent=0;
19377 101 byte moving_fairy_magic=0;
19378 101 byte moving_fairy_magic_percent=0;
19379 101 byte stationary_fairy_magic=0;
19380 101 byte stationary_fairy_magic_percent=0;
19381 101 byte blue_potion_hearts=100;
19382 101 byte blue_potion_heart_percent=1;
19383 101 byte red_potion_hearts=100;
19384 101 byte red_potion_heart_percent=1;
19385 101 byte blue_potion_magic=100;
19386 101 byte blue_potion_magic_percent=1;
19387 101 byte red_potion_magic=100;
19388 101 byte red_potion_magic_percent=1;
19389
19390 101 byte bomb_ratio = 4;
19391
19392 101 subscr_mode = 0;
19393
19394 /* HIGHLY UNORTHODOX UPDATING THING, by L
19395 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19396 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19397 * changing from 13 to 14.
19398 */
19399
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
101 if(s_version < 14)
19400 16 fixpolsvoice=true;
19401
19402 /* End highly unorthodox updating thing */
19403
19404
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 10 times.
101 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19405 10 temp_zinit.jump_hero_layer_threshold=0;
19406
19407
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 85 times.
101 if(s_version >= 10)
19408 {
19409 char temp;
19410
19411 //new-style items
19412
2/2
✓ Branch 0 taken 21760 times.
✓ Branch 1 taken 85 times.
21845 for(int32_t j=0; j<256; j++)
19413 {
19414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21760 times.
21760 if(!p_getc(&temp,f))
19415 return qe_invalid;
19416
19417 21760 temp_zinit.set_item(j, temp != 0);
19418 21760 }
19419 85 }
19420
19421
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19422 {
19423 char temp;
19424
19425 //finally... section data
19426
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97 if((Header->zelda_version > 0x192)||
19427 //new only
19428 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19429 {
19430 //OLD-style items... sigh
19431
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
97 if(s_version < 10)
19432 {
19433
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19434 {
19435 return qe_invalid;
19436 }
19437
19438 12 temp_zinit.set_item(iRaft, temp != 0);
19439
19440
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19441 {
19442 return qe_invalid;
19443 }
19444
19445 12 temp_zinit.set_item(iLadder, temp != 0);
19446
19447
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19448 {
19449 return qe_invalid;
19450 }
19451
19452 12 temp_zinit.set_item(iBook, temp != 0);
19453
19454
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19455 {
19456 return qe_invalid;
19457 }
19458
19459 12 temp_zinit.set_item(iMKey, temp != 0);
19460
19461
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19462 {
19463 return qe_invalid;
19464 }
19465
19466 12 temp_zinit.set_item(iFlippers, temp != 0);
19467
19468
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19469 {
19470 return qe_invalid;
19471 }
19472
19473 12 temp_zinit.set_item(iBoots, temp != 0);
19474 12 }
19475 97 }
19476
19477
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
97 if(s_version < 10)
19478 {
19479 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19480
19481
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempring,f))
19482 {
19483 return qe_invalid;
19484 }
19485
19486
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempsword,f))
19487 {
19488 return qe_invalid;
19489 }
19490
19491
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempshield,f))
19492 {
19493 return qe_invalid;
19494 }
19495
19496
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempwallet,f))
19497 {
19498 return qe_invalid;
19499 }
19500
19501
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempbracelet,f))
19502 {
19503 return qe_invalid;
19504 }
19505
19506
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempamulet,f))
19507 {
19508 return qe_invalid;
19509 }
19510
19511
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempbow,f))
19512 {
19513 return qe_invalid;
19514 }
19515
19516 //old only
19517
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19518 {
19519 tempring=(tempring)?(1<<(tempring-1)):0;
19520 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19521 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19522 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19523 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19524 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19525 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19526 }
19527
19528 //rings start at level 2... wtf
19529 //account for this -DD
19530 12 tempring <<= 1;
19531 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19532 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19533 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19534 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19535 //bracelet ALSO starts at level 2 :-( -DD
19536 12 tempbracelet<<=1;
19537 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19538 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19539 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19540
19541 //new only
19542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19543 {
19544 for(int32_t q=0; q<32; q++)
19545 {
19546 if(!p_getc(&padding,f))
19547 {
19548 return qe_invalid;
19549 }
19550 }
19551 }
19552
19553 char tempcandle, tempboomerang, temparrow, tempwhistle;
19554
19555
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempcandle,f))
19556 {
19557 return qe_invalid;
19558 }
19559
19560
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempboomerang,f))
19561 {
19562 return qe_invalid;
19563 }
19564
19565
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temparrow,f))
19566 {
19567 return qe_invalid;
19568 }
19569
19570
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19571 {
19572 return qe_invalid;
19573 }
19574
19575 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19576
19577
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempwhistle,f))
19578 {
19579 return qe_invalid;
19580 }
19581
19582 //old only
19583
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19584 {
19585 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19586 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19587 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19588 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19589 }
19590
19591 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19592 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19593 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19594 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19595 //What about the potion...?
19596
19597 12 }
19598
19599
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 89 times.
97 if(s_version < 29)
19600 {
19601 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19602 //to jab out my eye...
19603
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_getc(&padding,f))
19604 return qe_invalid;
19605 89 temp_zinit.counter[crBOMBS] = padding;
19606
19607
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_getc(&padding,f))
19608 return qe_invalid;
19609 89 temp_zinit.counter[crSBOMBS] = padding;
19610 89 }
19611
19612 //Back to more OLD item code
19613
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
97 if(s_version < 10)
19614 {
19615
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19616 //new only
19617 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19618 {
19619
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19620 {
19621 return qe_invalid;
19622 }
19623
19624 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19625
19626
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19627 {
19628 return qe_invalid;
19629 }
19630
19631 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19632
19633
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19634 {
19635 return qe_invalid;
19636 }
19637
19638 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19639
19640
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19641 {
19642 return qe_invalid;
19643 }
19644
19645 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19646
19647
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19648 {
19649 return qe_invalid;
19650 }
19651
19652 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19653
19654
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19655 {
19656 return qe_invalid;
19657 }
19658
19659 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19660
19661
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19662 {
19663 return qe_invalid;
19664 }
19665
19666 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19667
19668
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19669 {
19670 return qe_invalid;
19671 }
19672
19673 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19674
19675
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19676 {
19677 return qe_invalid;
19678 }
19679
19680 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19681
19682
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19683 {
19684 return qe_invalid;
19685 }
19686
19687
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19688 {
19689 for(int32_t q=0; q<32; q++)
19690 {
19691 if(!p_getc(&padding,f))
19692 {
19693 return qe_invalid;
19694 }
19695 }
19696 }
19697 12 }
19698 12 }
19699
19700 //old only
19701
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97 if((Header->zelda_version == 0x192)&&(Header->build<174))
19702 {
19703 byte equipment, tmpitm; //bit flags
19704
19705 if(!p_getc(&equipment,f))
19706 {
19707 return qe_invalid;
19708 }
19709
19710 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19711 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19712 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19713 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19714 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19715 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19716
19717
19718 if(!p_getc(&tmpitm,f))
19719 {
19720 return qe_invalid;
19721 }
19722
19723 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19724 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19725 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19726 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19727 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19728 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19729 }
19730
19731
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&tempbyte,f))
19732 return qe_invalid;
19733 97 temp_zinit.mcounter[crLIFE] = tempbyte;
19734
19735
19736
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version < 14)
19737 {
19738 byte temphp;
19739
19740
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temphp,f))
19741 {
19742 return qe_invalid;
19743 }
19744
19745 12 temp_zinit.counter[crLIFE]=temphp;
19746
19747
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temphp,f))
19748 {
19749 return qe_invalid;
19750 }
19751
19752 12 temp_zinit.cont_heart=temphp;
19753 12 }
19754 else
19755 {
19756
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19757 {
19758 return qe_invalid;
19759 }
19760
19761
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.cont_heart,f))
19762 {
19763 return qe_invalid;
19764 }
19765 }
19766
19767
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_zinit.hcp,f))
19768 {
19769 return qe_invalid;
19770 }
19771
19772
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version >= 14)
19773 {
19774
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19775 {
19776 return qe_invalid;
19777 }
19778
19779
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(s_version<16) // July 2007
19780 {
19781 if(get_qr(qr_BRANGPICKUP+1))
19782 temp_zinit.hcp_per_hc = 0xFF;
19783
19784 //Dispose of legacy rule
19785 set_qr(qr_BRANGPICKUP+1, 0);
19786 }
19787 85 }
19788
19789
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 89 times.
97 if(s_version < 29)
19790 {
19791
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_getc(&padding,f))
19792 return qe_invalid;
19793 89 temp_zinit.mcounter[crBOMBS] = padding;
19794 89 }
19795
19796
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19797 {
19798 return qe_invalid;
19799 }
19800
19801
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19802 {
19803 return qe_invalid;
19804 }
19805
19806
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&tempbyte,f))
19807 return qe_invalid;
19808
2/2
✓ Branch 0 taken 776 times.
✓ Branch 1 taken 97 times.
873 for(int q = 0; q < 8; ++q)
19809 776 set_bit(temp_zinit.mcguffin, q+1, get_bitl(tempbyte, q));
19810
19811
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19812 {
19813
2/2
✓ Branch 0 taken 5440 times.
✓ Branch 1 taken 85 times.
5525 for(int32_t i=0; i<64; i++)
19814 {
19815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5440 times.
5440 if(!p_getc(&temp_zinit.map[i],f))
19816 {
19817 return qe_invalid;
19818 }
19819 5440 }
19820
19821
2/2
✓ Branch 0 taken 5440 times.
✓ Branch 1 taken 85 times.
5525 for(int32_t i=0; i<64; i++)
19822 {
19823
1/2
✓ Branch 0 taken 5440 times.
✗ Branch 1 not taken.
5440 if(!p_getc(&temp_zinit.compass[i],f))
19824 {
19825 return qe_invalid;
19826 }
19827 5440 }
19828 85 }
19829 else
19830 {
19831
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19832 {
19833
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_zinit.map[i],f))
19834 {
19835 return qe_invalid;
19836 }
19837 384 }
19838
19839
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19840 {
19841
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_zinit.compass[i],f))
19842 {
19843 return qe_invalid;
19844 }
19845 384 }
19846 }
19847
19848
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97 if((Header->zelda_version > 0x192)||
19849 //new only
19850 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19851 {
19852
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19853 {
19854
2/2
✓ Branch 0 taken 5440 times.
✓ Branch 1 taken 85 times.
5525 for(int32_t i=0; i<64; i++)
19855 {
19856
1/2
✓ Branch 0 taken 5440 times.
✗ Branch 1 not taken.
5440 if(!p_getc(&temp_zinit.boss_key[i],f))
19857 {
19858 return qe_invalid;
19859 }
19860 5440 }
19861 85 }
19862 else
19863 {
19864
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19865 {
19866
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
19867 {
19868 return qe_invalid;
19869 }
19870 384 }
19871 }
19872 97 }
19873
19874 byte tmpmisc[16];
19875
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 97 times.
1649 for(int32_t i=0; i<16; i++)
19876
1/2
✓ Branch 0 taken 1552 times.
✗ Branch 1 not taken.
1552 if(!p_getc(&tmpmisc[i],f))
19877 return qe_invalid;
19878 97 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19879 97 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19880 97 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19881
19882
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
145 if(s_version < 15) for(int32_t i=0; i<4; i++)
19883
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&sword_hearts[i],f))
19884 12 return qe_invalid;
19885
19886
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_zinit.last_map,f))
19887 {
19888 return qe_invalid;
19889 }
19890
19891
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_zinit.last_screen,f))
19892 {
19893 return qe_invalid;
19894 }
19895
19896
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version < 14)
19897 {
19898 byte tempmp;
19899
19900
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempmp,f))
19901 {
19902 return qe_invalid;
19903 }
19904
19905 12 temp_zinit.mcounter[crMAGIC]=tempmp;
19906
19907
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempmp,f))
19908 {
19909 return qe_invalid;
19910 }
19911
19912 12 temp_zinit.counter[crMAGIC]=tempmp;
19913 12 }
19914 else
19915 {
19916
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19917 {
19918 return qe_invalid;
19919 }
19920
19921
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19922 {
19923 return qe_invalid;
19924 }
19925 }
19926
19927
19928
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version < 15)
19929 {
19930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
19931 {
19932 12 temp_zinit.mcounter[crMAGIC]*=32;
19933 12 temp_zinit.counter[crMAGIC]*=32;
19934 12 }
19935
19936
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t i=0; i<4; i++)
19937 {
19938
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&beam_hearts[i],f))
19939 {
19940 return qe_invalid;
19941 }
19942 48 }
19943
19944
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&beam_percent,f))
19945 {
19946 return qe_invalid;
19947 }
19948 12 }
19949 else
19950 {
19951
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_getc(&temp_zinit.bomb_ratio,f))
19952 return qe_invalid;
19953
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(temp_zinit.bomb_ratio < 1)
19954 temp_zinit.bomb_ratio = 1;
19955 85 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19956 }
19957
19958
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
97 if(s_version < 15)
19959 {
19960 byte tempbp;
19961
19962
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t i=0; i<4; i++)
19963 {
19964
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19965 {
19966 return qe_invalid;
19967 }
19968
19969 48 beam_power[i]=tempbp;
19970 48 }
19971
19972
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&hookshot_links,f))
19973 {
19974 return qe_invalid;
19975 }
19976
19977
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(s_version>6)
19978 {
19979 if(!p_getc(&hookshot_length,f))
19980 {
19981 return qe_invalid;
19982 }
19983
19984 if(!p_getc(&longshot_links,f))
19985 {
19986 return qe_invalid;
19987 }
19988
19989 if(!p_getc(&longshot_length,f))
19990 {
19991 return qe_invalid;
19992 }
19993 }
19994 12 }
19995
19996
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_zinit.msg_more_x,f))
19997 {
19998 return qe_invalid;
19999 }
20000
20001
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_zinit.msg_more_y,f))
20002 {
20003 return qe_invalid;
20004 }
20005
20006
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&subscr_mode,f))
20007 return qe_invalid;
20008
20009 //old only
20010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97 if((Header->zelda_version == 0x192)&&(Header->build<174))
20011 {
20012 for(int32_t i=0; i<32; i++)
20013 {
20014 if(!p_getc(&temp_zinit.boss_key[i],f))
20015 {
20016 return qe_invalid;
20017 }
20018 }
20019 }
20020
20021
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
97 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20022 {
20023
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version <= 10)
20024 {
20025
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempbyte,f))
20026 {
20027 return qe_invalid;
20028 }
20029
20030 12 temp_zinit.start_dmap = (word)tempbyte;
20031 12 }
20032 else
20033 {
20034
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.start_dmap,f))
20035 {
20036 return qe_invalid;
20037 }
20038 }
20039
20040
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20041 {
20042 return qe_invalid;
20043 }
20044 97 }
20045
20046
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 77 times.
97 if(s_version>1 && s_version < 29)
20047 {
20048
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&padding,f))
20049 return qe_invalid;
20050 77 temp_zinit.counter[crARROWS] = padding;
20051
20052
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&padding,f))
20053 return qe_invalid;
20054 77 temp_zinit.mcounter[crARROWS] = padding;
20055 77 }
20056
20057
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version>2)
20058 {
20059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if(s_version <= 10)
20060 {
20061 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20062 {
20063 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20064 {
20065 return qe_invalid;
20066 }
20067 }
20068 }
20069 else
20070 {
20071
2/2
✓ Branch 0 taken 43520 times.
✓ Branch 1 taken 85 times.
43605 for(int32_t i=0; i<MAXLEVELS; i++)
20072 {
20073
1/2
✓ Branch 0 taken 43520 times.
✗ Branch 1 not taken.
43520 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20074 {
20075 return qe_invalid;
20076 }
20077 43520 }
20078 }
20079 85 }
20080
20081
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version>3)
20082 {
20083
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20084 {
20085 return qe_invalid;
20086 }
20087
20088
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20089 {
20090 return qe_invalid;
20091 }
20092
20093
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20094 {
20095 return qe_invalid;
20096 }
20097
20098
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20099 {
20100 return qe_invalid;
20101 }
20102
20103
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20104 {
20105 return qe_invalid;
20106 }
20107
20108
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20109 {
20110 return qe_invalid;
20111 }
20112
20113
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20114 {
20115 return qe_invalid;
20116 }
20117
20118
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.ss_flags,f))
20119 {
20120 return qe_invalid;
20121 }
20122
20123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20125 85 }
20126
20127
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
97 if(s_version>4 && s_version<15)
20128 {
20129 if(!p_getc(&moving_fairy_hearts,f))
20130 {
20131 return qe_invalid;
20132 }
20133
20134 if(!p_getc(&moving_fairy_heart_percent,f))
20135 {
20136 return qe_invalid;
20137 }
20138 }
20139
20140
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
97 if(s_version>5 && s_version < 10)
20141 {
20142 if(!p_getc(&temp,f))
20143 {
20144 return qe_invalid;
20145 }
20146
20147 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20148 }
20149
20150
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
97 if(s_version>6 && s_version<15)
20151 {
20152 if(!p_getc(&stationary_fairy_hearts,f))
20153 {
20154 return qe_invalid;
20155 }
20156
20157 if(!p_getc(&stationary_fairy_heart_percent,f))
20158 {
20159 return qe_invalid;
20160 }
20161
20162 if(!p_getc(&moving_fairy_magic,f))
20163 {
20164 return qe_invalid;
20165 }
20166
20167 if(!p_getc(&moving_fairy_magic_percent,f))
20168 {
20169 return qe_invalid;
20170 }
20171
20172 if(!p_getc(&stationary_fairy_magic,f))
20173 {
20174 return qe_invalid;
20175 }
20176
20177 if(!p_getc(&stationary_fairy_magic_percent,f))
20178 {
20179 return qe_invalid;
20180 }
20181
20182 if(!p_getc(&blue_potion_hearts,f))
20183 {
20184 return qe_invalid;
20185 }
20186
20187 if(!p_getc(&blue_potion_heart_percent,f))
20188 {
20189 return qe_invalid;
20190 }
20191
20192 if(!p_getc(&red_potion_hearts,f))
20193 {
20194 return qe_invalid;
20195 }
20196
20197 if(!p_getc(&red_potion_heart_percent,f))
20198 {
20199 return qe_invalid;
20200 }
20201
20202 if(!p_getc(&blue_potion_magic,f))
20203 {
20204 return qe_invalid;
20205 }
20206
20207 if(!p_getc(&blue_potion_magic_percent,f))
20208 {
20209 return qe_invalid;
20210 }
20211
20212 if(!p_getc(&red_potion_magic,f))
20213 {
20214 return qe_invalid;
20215 }
20216
20217 if(!p_getc(&red_potion_magic_percent,f))
20218 {
20219 return qe_invalid;
20220 }
20221 }
20222
20223
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version>6)
20224
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_getc(&padding,f))
20225 return qe_invalid;
20226
20227
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version>7)
20228 {
20229
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_getc(&padding,f))
20230 {
20231 return qe_invalid;
20232 }
20233 85 }
20234
20235
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version>8)
20236 {
20237
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20238 {
20239 return qe_invalid;
20240 }
20241
20242
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20243 {
20244 return qe_invalid;
20245 }
20246 85 }
20247
20248
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 12 times.
97 if(s_version>16)
20249 {
20250
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_getc(&tempbyte,f))
20251 {
20252 return qe_invalid;
20253 }
20254 85 temp_zinit.gravity = tempbyte*100;
20255
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_igetw(&temp_zinit.terminalv,f))
20256 {
20257 return qe_invalid;
20258 }
20259
20260
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_getc(&temp_zinit.msg_speed,f))
20261 {
20262 return qe_invalid;
20263 }
20264
20265
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_getc(&padding,f))
20266 {
20267 return qe_invalid;
20268 }
20269
20270
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20271 {
20272 return qe_invalid;
20273 }
20274 85 }
20275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if (replay_version_check(0, 13))
20276 12 temp_zinit.msg_speed = 0;
20277
20278
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 85 times.
97 if(s_version>17)
20279 {
20280
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20281 {
20282 return qe_invalid;
20283 }
20284 85 }
20285
20286 //expaned init data for larger values in 2.55
20287
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 8 times.
97 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20288 {
20289
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20290 {
20291 return qe_invalid;
20292 }
20293
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20294 {
20295 return qe_invalid;
20296 }
20297
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20298 {
20299 return qe_invalid;
20300 }
20301
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20302 {
20303 return qe_invalid;
20304 }
20305
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20306 {
20307 return qe_invalid;
20308 }
20309
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20310 {
20311 return qe_invalid;
20312 }
20313
20314 8 }
20315
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 89 times.
97 if ( s_version >= 20 )
20316 {
20317
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.heroStep,f))
20318 {
20319 return qe_invalid;
20320 }
20321 8 }
20322 else
20323 {
20324 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20325 }
20326
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 89 times.
97 if ( s_version >= 21 )
20327 {
20328
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20329 {
20330 return qe_invalid;
20331 }
20332 8 }
20333 else
20334 {
20335 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20336 }
20337 //old only
20338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97 if((Header->zelda_version == 0x192)&&(Header->build<174))
20339 {
20340 byte items2;
20341
20342 if(!p_getc(&items2,f))
20343 {
20344 return qe_invalid;
20345 }
20346
20347 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20348 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20349 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20350 }
20351
20352
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(Header->zelda_version < 0x193)
20353 {
20354 for(int32_t q=0; q<96; q++)
20355 {
20356 if(!p_getc(&padding,f))
20357 {
20358 return qe_invalid;
20359 }
20360 }
20361
20362 //new only
20363 if((Header->zelda_version == 0x192)&&(Header->build>173))
20364 {
20365 if(!p_getc(&padding,f))
20366 {
20367 return qe_invalid;
20368 }
20369
20370 if(!p_getc(&padding,f))
20371 {
20372 return qe_invalid;
20373 }
20374 }
20375 }
20376 97 }
20377
20378
3/6
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20379 {
20380 //temp_zinit.shield=i_smallshield;
20381 16 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20382
20383
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20384 16 temp_zinit.set_item(sshieldid, true);
20385 16 }
20386
20387
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20388 {
20389 4 temp_zinit.mcounter[crLIFE]=3;
20390 4 temp_zinit.counter[crLIFE]=3;
20391 4 temp_zinit.cont_heart=3;
20392 4 temp_zinit.mcounter[crBOMBS]=8;
20393 4 }
20394
20395
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20396 {
20397 4 sword_hearts[0]=0;
20398 4 sword_hearts[1]=5;
20399 4 sword_hearts[2]=12;
20400 4 sword_hearts[3]=21;
20401 4 }
20402
20403
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20404 {
20405 4 temp_zinit.last_map=0;
20406 4 temp_zinit.last_screen=0;
20407 4 }
20408
20409
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20410 {
20411 4 temp_zinit.mcounter[crMAGIC]=0;
20412 4 temp_zinit.counter[crMAGIC]=0;
20413 4 temp_zinit.magicdrainrate = 2;
20414 4 }
20415
20416
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20417 {
20418
20419
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20420 {
20421 16 beam_hearts[x]=100;
20422 16 }
20423
20424
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20425 {
20426 16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20427 16 set_qr(qr_LENSHINTS+i,0);
20428 16 }
20429
20430
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20431 {
20432 16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20433 16 }
20434
20435 4 set_qr(qr_HIDECARRIEDITEMS,0);
20436 4 hookshot_links=100;
20437 4 temp_zinit.msg_more_x=224;
20438 4 temp_zinit.msg_more_y=64;
20439 4 }
20440
20441 // Okay, let's put these legacy values into itemsbuf.
20442
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
101 if(s_version < 15)
20443
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20444 {
20445
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20446 {
20447 case iFairyStill:
20448 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20449 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20450 16 itemsbuf[i].misc3 = 0;
20451 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20452 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20453 16 break;
20454
20455 case iFairyMoving:
20456 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20457 16 itemsbuf[i].misc2 = moving_fairy_magic;
20458 16 itemsbuf[i].misc3 = 50;
20459 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20460 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20461 16 break;
20462
20463 case iRPotion:
20464 16 itemsbuf[i].misc1 = red_potion_hearts;
20465 16 itemsbuf[i].misc2 = red_potion_magic;
20466 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20467 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20468 16 break;
20469
20470 case iBPotion:
20471 16 itemsbuf[i].misc1 = blue_potion_hearts;
20472 16 itemsbuf[i].misc2 = blue_potion_magic;
20473 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20474 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20475 16 break;
20476
20477 case iSword:
20478 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20479 16 itemsbuf[i].misc1 = beam_hearts[0];
20480 16 itemsbuf[i].misc2 = beam_power[0];
20481 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20482 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20483 16 break;
20484
20485 case iWSword:
20486 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20487 16 itemsbuf[i].misc1 = beam_hearts[1];
20488 16 itemsbuf[i].misc2 = beam_power[1];
20489 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20490 16 break;
20491
20492 case iMSword:
20493 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20494 16 itemsbuf[i].misc1 = beam_hearts[2];
20495 16 itemsbuf[i].misc2 = beam_power[2];
20496 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20497 16 break;
20498
20499 case iXSword:
20500 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20501 16 itemsbuf[i].misc1 = beam_hearts[3];
20502 16 itemsbuf[i].misc2 = beam_power[3];
20503 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20504 16 break;
20505
20506 case iHookshot:
20507 16 itemsbuf[i].misc1 = hookshot_length;
20508 16 itemsbuf[i].misc2 = hookshot_links;
20509 16 break;
20510
20511 case iLongshot:
20512 16 itemsbuf[i].misc1 = longshot_length;
20513 16 itemsbuf[i].misc2 = longshot_links;
20514 16 break;
20515 }
20516 4112 }
20517
20518
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20519 {
20520 //was new subscreen rule
20521 4 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20522 4 set_qr(qr_FREEFORM,0);
20523 4 }
20524
20525
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20526 {
20527 4 temp_zinit.start_dmap=0;
20528 4 }
20529
20530
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
101 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20531 {
20532 4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20533 4 }
20534
20535
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
101 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20536 {
20537 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20538 temp_zinit.mcounter[crMONEY]=999;
20539 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20540 }
20541
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20542 {
20543 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20544 temp_zinit.mcounter[crBOMBS] = 8;
20545 }
20546 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20547 //time to ensure that we port all new values properly:
20548
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 16 times.
101 if(Header->zelda_version < 0x250)
20549 {
20550
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20551 16 }
20552
20553
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 93 times.
101 if(s_version > 21)
20554 {
20555
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.hp_per_heart,f))
20556 {
20557 return qe_invalid;
20558 }
20559
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.magic_per_block,f))
20560 {
20561 return qe_invalid;
20562 }
20563
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20564 {
20565 return qe_invalid;
20566 }
20567
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20568 {
20569 return qe_invalid;
20570 }
20571 8 }
20572 else
20573 {
20574 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20575 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20576 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20577 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20578 }
20579
20580
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 8 times.
101 if(s_version > 22)
20581 {
20582
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 8 times.
208 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(!p_igetw(&temp_zinit.counter[q],f))
20584 return qe_invalid;
20585
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 8 times.
208 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(!p_igetw(&temp_zinit.mcounter[q],f))
20587 return qe_invalid;
20588 8 }
20589
20590
20591
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 93 times.
101 if(s_version > 23)
20592 {
20593
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.dither_type,f))
20594 {
20595 return qe_invalid;
20596 }
20597
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.dither_arg,f))
20598 {
20599 return qe_invalid;
20600 }
20601
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.dither_percent,f))
20602 {
20603 return qe_invalid;
20604 }
20605
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.def_lightrad,f))
20606 {
20607 return qe_invalid;
20608 }
20609
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.transdark_percent,f))
20610 {
20611 return qe_invalid;
20612 }
20613 8 }
20614 else
20615 {
20616 93 temp_zinit.dither_type = 0;
20617 93 temp_zinit.dither_arg = 0;
20618 93 temp_zinit.dither_percent = 20;
20619 93 temp_zinit.def_lightrad = 24;
20620 93 temp_zinit.transdark_percent = 0;
20621 }
20622
20623
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 93 times.
101 if(s_version > 24)
20624 {
20625
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.darkcol,f))
20626 {
20627 return qe_invalid;
20628 }
20629 8 }
20630 else
20631 {
20632 93 temp_zinit.darkcol = BLACK;
20633 }
20634
20635
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 8 times.
101 if(s_version > 25)
20636 {
20637
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&temp_zinit.gravity,f))
20638 {
20639 return qe_invalid;
20640 }
20641
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&temp_zinit.swimgravity,f))
20642 {
20643 return qe_invalid;
20644 }
20645 8 }
20646
20647
20648
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 93 times.
101 if(s_version > 26)
20649 {
20650
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20651 {
20652 return qe_invalid;
20653 }
20654
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20655 {
20656 return qe_invalid;
20657 }
20658
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20659 {
20660 return qe_invalid;
20661 }
20662 8 }
20663 else
20664 {
20665 93 temp_zinit.heroSideswimUpStep = 150;
20666 93 temp_zinit.heroSideswimSideStep = 100;
20667 93 temp_zinit.heroSideswimDownStep = 75;
20668 }
20669
20670
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 93 times.
101 if(s_version > 27)
20671 {
20672
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20673 {
20674 return qe_invalid;
20675 }
20676 8 }
20677 else
20678 {
20679 93 temp_zinit.exitWaterJump = 0;
20680 }
20681
20682
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 93 times.
101 if(s_version > 29)
20683 {
20684
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20685 {
20686 return qe_invalid;
20687 }
20688 8 }
20689 else
20690 {
20691 93 temp_zinit.bunny_ltm = 0;
20692 }
20693
20694
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 93 times.
101 if(s_version > 30)
20695 {
20696
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.switchhookstyle,f))
20697 {
20698 return qe_invalid;
20699 }
20700 8 }
20701 else
20702 {
20703 93 temp_zinit.switchhookstyle = 1;
20704 }
20705
20706
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 8 times.
101 if(s_version > 31)
20707 {
20708
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_zinit.magicdrainrate,f))
20709 {
20710 return qe_invalid;
20711 }
20712 8 }
20713
20714 101 temp_zinit.clear_genscript();
20715
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 6 times.
101 if(s_version > 32)
20716 {
20717 6 word numgenscript = 0;
20718
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_igetw(&numgenscript,f))
20719 return qe_invalid;
20720
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20721 return qe_invalid;
20722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 for(auto q = 1; q < numgenscript; ++q)
20723 {
20724 if(!p_getc(&tempbyte,f))
20725 return qe_invalid;
20726 if(!(tempbyte&2))
20727 continue;
20728 temp_zinit.gen_doscript.set(q, tempbyte&1);
20729 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20730 return qe_invalid;
20731 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20732 return qe_invalid;
20733 for(auto p = 0; p < 8; ++p)
20734 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20735 return qe_invalid;
20736 dword sz;
20737 if(!p_igetl(&sz,f))
20738 return qe_invalid;
20739 temp_zinit.gen_data[q].resize(sz);
20740 std::vector<int32_t> dummy;
20741 if(!p_getlvec(&dummy,f))
20742 return qe_invalid;
20743 temp_zinit.gen_data[q] = dummy;
20744 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20745 return qe_invalid;
20746 }
20747 6 }
20748
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
101 if(s_version > 33)
20749 {
20750
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20751 return qe_invalid;
20752
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_zinit.hero_swim_div,f))
20753 return qe_invalid;
20754 4 }
20755
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(s_version > 34)
20756 {
20757 uint32_t num_used_mapscr_data;
20758 if(!p_igetl(&num_used_mapscr_data,f))
20759 return qe_invalid;
20760 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20761 {
20762 uint32_t sz;
20763 if(!p_igetl(&sz,f))
20764 return qe_invalid;
20765 temp_zinit.screen_data[q].resize(sz);
20766 if(sz)
20767 {
20768 std::vector<int32_t> dummy;
20769 if(!p_getlvec(&dummy,f))
20770 return qe_invalid;
20771 temp_zinit.screen_data[q] = dummy;
20772 }
20773 }
20774 }
20775
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if (s_version > 35)
20776 if(!p_igetzf(&temp_zinit.shove_offset,f))
20777 return qe_invalid;
20778
20779 101 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20780 101 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20781
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 63 times.
101 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20782 63 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20783
20784 101 return 0;
20785 101 }
20786 130 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20787 {
20788 130 zinitdata temp_zinit = {};
20789
20790
3/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
130 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20791
20792 int32_t dummy;
20793 130 word s_version=0, s_cversion=0;
20794 byte padding;
20795
20796
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(Header->zelda_version > 0x192)
20797 {
20798
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_version,f))
20799 return qe_invalid;
20800 126 FFCore.quest_format[vInitData] = s_version;
20801
20802
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetw(&s_cversion,f))
20803 return qe_invalid;
20804
20805 //section size
20806
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!p_igetl(&dummy,f))
20807 return qe_invalid;
20808 126 }
20809
20810
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 29 times.
130 if(s_version < 37)
20811 {
20812
2/4
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
101 if(auto ret = readinitdata_old(f,Header,s_version,s_cversion,temp_zinit))
20813 return ret;
20814 101 }
20815 else
20816 {
20817 29 subscr_mode = ssdtMAX;
20818
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 29 times.
957 for(int q = 0; q < MAXITEMS/8; ++q)
20819
2/4
✓ Branch 0 taken 928 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 928 times.
928 if(!p_getc(&temp_zinit.items[q], f))
20820 return qe_invalid;
20821
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1856 times.
1885 for(int q = 0; q < MAXLEVELS/8; ++q)
20822 {
20823
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1856 times.
✗ Branch 3 not taken.
1856 if(!p_getc(&temp_zinit.map[q], f))
20824 return qe_invalid;
20825
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1856 times.
1856 if(!p_getc(&temp_zinit.compass[q], f))
20826 return qe_invalid;
20827
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1856 times.
1856 if(!p_getc(&temp_zinit.boss_key[q], f))
20828 return qe_invalid;
20829
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1856 times.
✗ Branch 3 not taken.
1856 if(!p_getc(&temp_zinit.mcguffin[q], f))
20830 return qe_invalid;
20831 1856 }
20832
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbvec(&temp_zinit.level_keys, f))
20833 return qe_invalid;
20834 byte num_counters;
20835
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&num_counters,f))
20836 return qe_invalid;
20837
2/2
✓ Branch 0 taken 3103 times.
✓ Branch 1 taken 29 times.
3132 for(int q = 0; q < num_counters; ++q)
20838
2/4
✓ Branch 0 taken 3103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3103 times.
3103 if(!p_igetw(&temp_zinit.counter[q],f))
20839 return qe_invalid;
20840
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3103 times.
3132 for(int q = 0; q < num_counters; ++q)
20841
2/4
✓ Branch 0 taken 3103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3103 times.
3103 if(!p_igetw(&temp_zinit.mcounter[q],f))
20842 return qe_invalid;
20843
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.bomb_ratio,f))
20844 return qe_invalid;
20845
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hcp,f))
20846 return qe_invalid;
20847
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20848 return qe_invalid;
20849
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.cont_heart,f))
20850 return qe_invalid;
20851
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hp_per_heart,f))
20852 return qe_invalid;
20853
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.magic_per_block,f))
20854 return qe_invalid;
20855
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20856 return qe_invalid;
20857
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20858 return qe_invalid;
20859
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_type,f))
20860 return qe_invalid;
20861
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_arg,f))
20862 return qe_invalid;
20863
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_percent,f))
20864 return qe_invalid;
20865
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.def_lightrad,f))
20866 return qe_invalid;
20867
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.transdark_percent,f))
20868 return qe_invalid;
20869
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.darkcol,f))
20870 return qe_invalid;
20871
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20872 return qe_invalid;
20873
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20874 return qe_invalid;
20875
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20876 return qe_invalid;
20877
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20878 return qe_invalid;
20879
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20880 return qe_invalid;
20881
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20882 return qe_invalid;
20883
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20884 return qe_invalid;
20885
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_flags,f))
20886 return qe_invalid;
20887
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbitstr(&temp_zinit.flags,f))
20888 return qe_invalid;
20889
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.last_map,f))
20890 return qe_invalid;
20891
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.last_screen,f))
20892 return qe_invalid;
20893
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.msg_more_x,f))
20894 return qe_invalid;
20895
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.msg_more_y,f))
20896 return qe_invalid;
20897
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20898 return qe_invalid;
20899
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.msg_speed,f))
20900 return qe_invalid;
20901
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.gravity,f))
20902 return qe_invalid;
20903
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.swimgravity,f))
20904 return qe_invalid;
20905
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.terminalv,f))
20906 return qe_invalid;
20907
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20908 return qe_invalid;
20909
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20910 return qe_invalid;
20911
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_swim_div,f))
20912 return qe_invalid;
20913
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20914 return qe_invalid;
20915
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20916 return qe_invalid;
20917
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20918 return qe_invalid;
20919
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20920 return qe_invalid;
20921
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroStep,f))
20922 return qe_invalid;
20923
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20924 return qe_invalid;
20925
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20926 return qe_invalid;
20927
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20928 return qe_invalid;
20929
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.start_dmap,f))
20930 return qe_invalid;
20931
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20932 return qe_invalid;
20933
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.switchhookstyle,f))
20934 return qe_invalid;
20935
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.magicdrainrate,f))
20936 return qe_invalid;
20937
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetzf(&temp_zinit.shove_offset,f))
20938 return qe_invalid;
20939
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20940 return qe_invalid;
20941
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20942 return qe_invalid;
20943
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20944 return qe_invalid;
20945
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_initd, f))
20946 return qe_invalid;
20947
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20948 return qe_invalid;
20949
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_data, f))
20950 return qe_invalid;
20951
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.screen_data, f))
20952 return qe_invalid;
20953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (s_version >= 38)
20954 {
20955 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
20956 return qe_invalid;
20957 if (!p_getc(&temp_zinit.spriteflickercolor, f))
20958 return qe_invalid;
20959 if (!p_getc(&temp_zinit.spriteflickertransp, f))
20960 return qe_invalid;
20961 }
20962 }
20963
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (should_skip)
20964 return 0;
20965
20966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(loading_tileset_flags & TILESET_CLEARMAPS)
20967 {
20968 temp_zinit.last_map = 0;
20969 temp_zinit.last_screen = 0;
20970 temp_zinit.screen_data.clear();
20971 }
20972
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 temp_zinit.normalize();
20973
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 zinit = temp_zinit;
20974
20975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(zinit.heroAnimationStyle==las_zelda3slow)
20976 {
20977 hero_animation_speed=2;
20978 }
20979 else
20980 {
20981 130 hero_animation_speed=1;
20982 }
20983
20984 130 return 0;
20985 130 }
20986
20987 /*
20988 void setupitemdropsets()
20989 {
20990 for(int32_t i=0; i<isMAX; i++)
20991 {
20992 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20993 }
20994 }
20995 */
20996
20997 118 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20998 {
20999
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 4 times.
118 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21000
21001 118 build=build; // here to prevent compiler warnings
21002 dword dummy_dword;
21003 118 word item_drop_sets_to_read=0;
21004 item_drop_object tempitemdrop;
21005 118 word s_version=0, s_cversion=0;
21006
21007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if (!should_skip)
21008
2/2
✓ Branch 0 taken 30208 times.
✓ Branch 1 taken 118 times.
30326 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21009 {
21010 30208 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21011 30326 }
21012
21013
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 4 times.
118 if(version > 0x192)
21014 {
21015 114 item_drop_sets_to_read=0;
21016
21017 //section version info
21018
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_version,f))
21019 {
21020 return qe_invalid;
21021 }
21022
21023 114 FFCore.quest_format[vItemDropsets] = s_version;
21024
21025 //al_trace("Item drop sets version %d\n", s_version);
21026
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
21027 {
21028 return qe_invalid;
21029 }
21030
21031 //section size
21032
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy_dword,f))
21033 {
21034 return qe_invalid;
21035 }
21036
21037 //finally... section data
21038
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&item_drop_sets_to_read,f))
21039 {
21040 return qe_invalid;
21041 }
21042
21043
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
21044 {
21045 return qe_invalid;
21046 }
21047 114 }
21048 else
21049 {
21050 4 init_item_drop_sets();
21051 }
21052
21053
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 114 times.
118 if(s_version>=1)
21054 {
21055
2/2
✓ Branch 0 taken 2068 times.
✓ Branch 1 taken 114 times.
2182 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21056 {
21057
1/2
✓ Branch 0 taken 2068 times.
✗ Branch 1 not taken.
2068 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21058 {
21059 return qe_invalid;
21060 }
21061
21062
2/2
✓ Branch 0 taken 20680 times.
✓ Branch 1 taken 2068 times.
22748 for(int32_t j=0; j<10; ++j)
21063 {
21064
1/2
✓ Branch 0 taken 20680 times.
✗ Branch 1 not taken.
20680 if(!p_igetw(&tempitemdrop.item[j],f))
21065 {
21066 return qe_invalid;
21067 }
21068 20680 }
21069
21070
2/2
✓ Branch 0 taken 22748 times.
✓ Branch 1 taken 2068 times.
24816 for(int32_t j=0; j<11; ++j)
21071 {
21072
1/2
✓ Branch 0 taken 22748 times.
✗ Branch 1 not taken.
22748 if(!p_igetw(&tempitemdrop.chance[j],f))
21073 {
21074 return qe_invalid;
21075 }
21076 22748 }
21077
21078 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21079 // overrides the quest's set #12.
21080
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2068 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2068 if(s_version<2 && i==12)
21081 continue;
21082
21083 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21084
1/4
✓ Branch 0 taken 2068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2068 if(s_version<2) for(int32_t j=0; j<10; ++j)
21085 {
21086 int32_t it = tempitemdrop.item[j];
21087
21088 if((itemsbuf[it].family == itype_rupee
21089 && ((itemsbuf[it].amount)&0xFFF) == 10)
21090 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21091 {
21092 tempitemdrop.chance[j+1]=0;
21093 }
21094 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21095 {
21096 tempitemdrop.chance[j+1]=0;
21097 }
21098
21099 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21100 if(itemsbuf[it].family == itype_misc)
21101 {
21102 // If a non-gameplay item was selected, then item drop was aborted.
21103 // Reflect this by increasing the 'Nothing' chance accordingly.
21104 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21105 tempitemdrop.chance[j+1]=0;
21106 }
21107 }
21108
21109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2068 times.
2068 if (!should_skip)
21110 2068 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21111 2068 }
21112 114 }
21113
21114 118 return 0;
21115 118 }
21116
21117 114 int32_t readfavorites(PACKFILE *f, int32_t, word)
21118 {
21119
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21120
21121 int32_t temp_num;
21122 dword dummy_dword;
21123 word num_favorite_combos;
21124 word num_favorite_combo_aliases;
21125 114 word s_version=0, s_cversion=0;
21126
21127 //section version info
21128
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_version,f))
21129 {
21130 return qe_invalid;
21131 }
21132
21133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (!should_skip)
21134 114 FFCore.quest_format[vFavourites] = s_version;
21135
21136
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&s_cversion,f))
21137 {
21138 return qe_invalid;
21139 }
21140
21141 //section size
21142
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&dummy_dword,f))
21143 {
21144 return qe_invalid;
21145 }
21146
21147 114 word per_row = FAVORITECOMBO_PER_ROW;
21148 114 word per_page = FAVORITECOMBO_PER_PAGE;
21149
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 33 times.
114 if(s_version >= 3)
21150
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&per_row,f))
21151 return qe_invalid;
21152
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 29 times.
114 if(s_version >= 4)
21153
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&per_page,f))
21154 return qe_invalid;
21155 //finally... section data
21156
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetw(&num_favorite_combos,f))
21157 {
21158 return qe_invalid;
21159 }
21160
21161 //Hack; port old favorite combos
21162
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
114 if(s_version < 3 && num_favorite_combos == 100)
21163 81 per_row = 13;
21164
21165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (!should_skip)
21166
2/2
✓ Branch 0 taken 143640 times.
✓ Branch 1 taken 114 times.
143754 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21167 143754 favorite_combos[q] = -1;
21168 114 byte favtype = 0;
21169
2/2
✓ Branch 0 taken 9269 times.
✓ Branch 1 taken 114 times.
9383 for(int32_t i=0; i<num_favorite_combos; i++)
21170 {
21171
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 8104 times.
9269 if (s_version >= 4)
21172 {
21173
1/2
✓ Branch 0 taken 1165 times.
✗ Branch 1 not taken.
1165 if (!p_getc(&favtype, f))
21174 {
21175 return qe_invalid;
21176 }
21177 1165 }
21178 else
21179 8104 favtype = 0;
21180
1/2
✓ Branch 0 taken 9269 times.
✗ Branch 1 not taken.
9269 if(!p_igetl(&temp_num,f))
21181 {
21182 return qe_invalid;
21183 }
21184
21185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9269 times.
9269 if (should_skip)
21186 continue;
21187
21188
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 8104 times.
9269 if(per_row == FAVORITECOMBO_PER_ROW)
21189 {
21190 1165 favorite_combos[i] = temp_num;
21191 1165 favorite_combo_modes[i] = favtype;
21192 1165 }
21193 else
21194 {
21195 8104 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21196 8104 favorite_combos[new_i]=temp_num;
21197 8104 favorite_combo_modes[new_i] = favtype;
21198 }
21199 9269 }
21200
21201 // Discard the separate favorite aliases list from previous versions
21202
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 85 times.
114 if(s_version<4)
21203 {
21204
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if (!p_igetw(&num_favorite_combo_aliases, f))
21205 {
21206 return qe_invalid;
21207 }
21208
21209
2/2
✓ Branch 0 taken 8100 times.
✓ Branch 1 taken 85 times.
8185 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21210 {
21211
1/2
✓ Branch 0 taken 8100 times.
✗ Branch 1 not taken.
8100 if (!p_igetl(&temp_num, f))
21212 {
21213 return qe_invalid;
21214 }
21215 8100 }
21216 85 }
21217
21218 114 word max_combo_cols = 0;
21219 114 word max_mappages = 0;
21220
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 33 times.
114 if(s_version >= 2)
21221 {
21222
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&max_combo_cols,f))
21223 return qe_invalid;
21224 33 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21225
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 33 times.
165 for(int q = 0; q < max_combo_cols; ++q)
21226 {
21227
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&tmp,f))
21228 return qe_invalid;
21229
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&tmp2,f))
21230 return qe_invalid;
21231
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&tmp3,f))
21232 return qe_invalid;
21233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(q < MAX_COMBO_COLS)
21234 {
21235 132 First[q] = tmp;
21236 132 combo_alistpos[q] = tmp2;
21237 132 combo_pool_listpos[q] = tmp3;
21238 132 }
21239 132 }
21240
21241
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&max_mappages,f))
21242 return qe_invalid;
21243
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 33 times.
330 for(int q = 0; q < max_mappages; ++q)
21244 {
21245
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if(!p_igetl(&tmp,f))
21246 return qe_invalid;
21247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(!p_igetl(&tmp2,f))
21248 return qe_invalid;
21249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(q < MAX_MAPPAGE_BTNS)
21250 {
21251 297 map_page[q].map = tmp;
21252 297 map_page[q].screen = tmp2;
21253 297 }
21254 297 }
21255 33 }
21256
21257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (should_skip)
21258 return 0;
21259
21260
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 114 times.
438 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21261 {
21262 324 First[q] = 0;
21263 324 combo_alistpos[q] = 0;
21264 324 combo_pool_listpos[q] = 0;
21265 324 }
21266
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 114 times.
843 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21267 {
21268 729 map_page[q].map = 0;
21269 729 map_page[q].screen = 0;
21270 729 }
21271
21272 114 return 0;
21273 114 }
21274
21275 /*
21276 switch (ret) {
21277 case 0:
21278 break;
21279
21280 case qe_invalid:
21281 goto invalid;
21282 break;
21283 default:
21284 pack_fclose(f);
21285 if(!oldquest)
21286 delete_file(tmpfilename);
21287 return ret;
21288 break;
21289 }
21290 */
21291
21292 const char *skip_text[skip_max]=
21293 {
21294 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21295 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21296 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21297 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21298 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21299 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21300 "skip_favorites"
21301 };
21302
21303
21304 void port250QuestRules(){
21305
21306 portCandleRules(); //Candle
21307 portBombRules();
21308
21309 }
21310
21311 void portCandleRules()
21312 {
21313 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21314 //itemdata itemsbuf;
21315 for ( int32_t q = 0; q < MAXITEMS; q++ )
21316 {
21317 if ( itemsbuf[q].family == itype_candle )
21318 {
21319 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21320 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21321 }
21322 }
21323 }
21324
21325 void portBombRules()
21326 {
21327 bool hurtshero = get_qr(qr_OUCHBOMBS);
21328 //itemdata itemsbuf;
21329 for ( int32_t q = 0; q < MAXITEMS; q++ )
21330 {
21331 if ( itemsbuf[q].family == itype_bomb )
21332 {
21333 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21334 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21335 }
21336 }
21337 }
21338
21339 2984 static int section_id_to_enum(int id)
21340 {
21341
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 130 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 130 times.
✓ Branch 6 taken 114 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 130 times.
✓ Branch 9 taken 130 times.
✓ Branch 10 taken 130 times.
✓ Branch 11 taken 130 times.
✓ Branch 12 taken 130 times.
✓ Branch 13 taken 114 times.
✓ Branch 14 taken 114 times.
✓ Branch 15 taken 130 times.
✓ Branch 16 taken 130 times.
✓ Branch 17 taken 118 times.
✓ Branch 18 taken 114 times.
✓ Branch 19 taken 114 times.
✓ Branch 20 taken 114 times.
✓ Branch 21 taken 130 times.
✓ Branch 22 taken 130 times.
✓ Branch 23 taken 118 times.
✓ Branch 24 taken 114 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2984 switch (id)
21342 {
21343 case ID_HEADER: return skip_header;
21344 130 case ID_RULES: return skip_rules;
21345 130 case ID_STRINGS: return skip_strings;
21346 130 case ID_MISC: return skip_misc;
21347 130 case ID_TILES: return skip_tiles;
21348 130 case ID_COMBOS: return skip_combos;
21349 114 case ID_COMBOALIASES: return skip_comboaliases;
21350 130 case ID_CSETS: return skip_csets;
21351 130 case ID_MAPS: return skip_maps;
21352 130 case ID_DMAPS: return skip_dmaps;
21353 130 case ID_DOORS: return skip_doors;
21354 130 case ID_ITEMS: return skip_items;
21355 130 case ID_WEAPONS: return skip_weapons;
21356 114 case ID_COLORS: return skip_colors;
21357 114 case ID_ICONS: return skip_icons;
21358 130 case ID_INITDATA: return skip_initdata;
21359 130 case ID_GUYS: return skip_guys;
21360 118 case ID_HEROSPRITES: return skip_herosprites;
21361 114 case ID_SUBSCREEN: return skip_subscreens;
21362 114 case ID_FFSCRIPT: return skip_ffscript;
21363 114 case ID_SFX: return skip_sfx;
21364 130 case ID_MIDIS: return skip_midis;
21365 130 case ID_CHEATS: return skip_cheats;
21366 118 case ID_ITEMDROPSETS: return skip_itemdropsets;
21367 114 case ID_FAVORITES: return skip_favorites;
21368 case ID_ZINFO: return skip_zinfo;
21369 }
21370
21371 return -1;
21372 2984 }
21373
21374 2916 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21375 {
21376 2916 int section_enum = section_id_to_enum(section_id);
21377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2916 times.
2916 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2916 times.
2916 if (skip)
21379 {
21380 word s_version;
21381 if (!p_igetw(&s_version,f))
21382 {
21383 return qe_invalid;
21384 }
21385
21386 word c_version;
21387 if (!p_igetw(&c_version,f))
21388 {
21389 return qe_invalid;
21390 }
21391
21392 if (section_id == ID_RULES && s_version > 16)
21393 {
21394 dword dummy;
21395 if (!p_igetl(&dummy,f))
21396 {
21397 return qe_invalid;
21398 }
21399 }
21400
21401 if (section_id == ID_FFSCRIPT && s_version >= 18)
21402 {
21403 word dummy;
21404 if (!p_igetw(&dummy,f))
21405 {
21406 return qe_invalid;
21407 }
21408 }
21409
21410 dword section_length;
21411 if (!p_igetl(&section_length,f))
21412 {
21413 return qe_invalid;
21414 }
21415
21416 if (pack_fseek(f, section_length))
21417 {
21418 return qe_invalid;
21419 }
21420
21421 if (!pack_feof(f))
21422 {
21423 if (!p_mgetl(&section_id,f))
21424 {
21425 return qe_invalid;
21426 }
21427 }
21428
21429 return qe_cancel;
21430 }
21431
21432 2916 return qe_OK;
21433 2916 }
21434
21435 //Internal function for loadquest wrapper
21436 130 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21437 {
21438 130 DMapEditorLastMaptileUsed = 0;
21439 130 combosread=false;
21440 130 mapsread=false;
21441 130 fixffcs=false;
21442
21443 130 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21444
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21445 {
21446 set_bit(skip_flags, skip_ffscript, 1);
21447 setZScriptVersion(V_FFSCRIPT);
21448 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21449 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21450 do_clear_scripts = true;
21451 }
21452
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(loading_tileset_flags & TILESET_CLEARMAPS)
21453 {
21454 set_bit(skip_flags, skip_maps, 1);
21455 }
21456
21457 // show_progress=true;
21458 char tmpfilename[L_tmpnam];
21459 130 temp_name(tmpfilename);
21460 // char percent_done[30];
21461 130 bool catchup=false;
21462 byte tempbyte;
21463 130 word old_map_count=map_count;
21464
21465 130 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21466 130 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21467 130 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21468
21469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(get_bit(skip_flags, skip_rules))
21470 {
21471 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21472 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21473 }
21474
21475 130 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21476 130 unpack_qrs();
21477 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21478
21479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(get_bit(skip_flags, skip_midis))
21480 {
21481 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21482 }
21483
21484
21485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(do_clear_scripts)
21486 {
21487 130 zScript.clear();
21488 130 globalmap.clear();
21489 130 genericmap.clear();
21490 130 ffcmap.clear();
21491 130 itemmap.clear();
21492 130 npcmap.clear();
21493 130 ewpnmap.clear();
21494 130 lwpnmap.clear();
21495 130 playermap.clear();
21496 130 dmapmap.clear();
21497 130 screenmap.clear();
21498 130 itemspritemap.clear();
21499 130 comboscriptmap.clear();
21500 130 subscreenmap.clear();
21501
21502
2/2
✓ Branch 0 taken 66430 times.
✓ Branch 1 taken 130 times.
66560 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21503 {
21504 66430 ffcmap[i].clear();
21505 66430 }
21506
21507 130 globalmap[0].slotname = "Slot 1:";
21508 130 globalmap[0].scriptname = "~Init";
21509 130 globalmap[0].update();
21510
21511
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 130 times.
1040 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21512 {
21513 910 globalmap[i].clear();
21514 910 }
21515
21516
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21517 {
21518 33150 itemmap[i].clear();
21519 33150 }
21520
21521 //new script types -- prevent carrying over to a quest that you load after reading them
21522 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21523
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21524 {
21525 33150 npcmap[i].clear();
21526 33150 }
21527
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21528 {
21529 33150 lwpnmap[i].clear();
21530 33150 }
21531
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21532 {
21533 33150 ewpnmap[i].clear();
21534 33150 }
21535
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 130 times.
650 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21536 {
21537 520 playermap[i].clear();
21538 520 }
21539
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21540 {
21541 33150 dmapmap[i].clear();
21542 33150 }
21543
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21544 {
21545 33150 screenmap[i].clear();
21546 33150 }
21547
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21548 {
21549 33150 itemspritemap[i].clear();
21550 33150 }
21551
2/2
✓ Branch 0 taken 66430 times.
✓ Branch 1 taken 130 times.
66560 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21552 {
21553 66430 comboscriptmap[i].clear();
21554 66430 }
21555
2/2
✓ Branch 0 taken 66430 times.
✓ Branch 1 taken 130 times.
66560 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21556 {
21557 66430 genericmap[i].clear();
21558 66430 }
21559
2/2
✓ Branch 0 taken 33150 times.
✓ Branch 1 taken 130 times.
33280 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21560 {
21561 33150 subscreenmap[i].clear();
21562 33150 }
21563
21564 130 reset_scripts();
21565 130 }
21566
21567 zquestheader tempheader;
21568 130 memset(&tempheader, 0, sizeof(zquestheader));
21569 130 zinfo tempzi;
21570 130 tempzi.clear();
21571 130 load_tmp_zi = &tempzi;
21572
21573 // oldquest flag is set when an unencrypted qst file is suspected.
21574 130 bool oldquest = false;
21575 130 int32_t open_error=0;
21576 130 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21577
21578
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (!f)
21579 {
21580 ASSERT(open_error != 0);
21581 return open_error;
21582 }
21583 char zinfofilename[2048];
21584 130 replace_extension(zinfofilename, filename, "zinfo", 2047);
21585 130 int32_t ret=0;
21586
21587 //header
21588 130 box_out("Reading Header...");
21589 130 ret=readheader(f, &tempheader, printmetadata);
21590
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
130 checkstatus(ret);
21591 130 box_out("okay.");
21592 130 box_eol();
21593
21594
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 37 times.
130 if(read_zinfo)
21595 {
21596 37 box_out("Reading ZInfo - ");
21597
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 36 times.
37 box_out(read_ext_zinfo ? "External..." : "Internal...");
21598
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 36 times.
37 if(read_ext_zinfo)
21599 {
21600 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21601 1 ret=readzinfo(inf, tempzi, tempheader);
21602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(inf) pack_fclose(inf);
21603
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21604 1 }
21605 else
21606 {
21607 36 ret=readzinfo(f, tempzi, tempheader);
21608
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
36 checkstatus(ret);
21609 }
21610 37 box_out("okay.");
21611 37 box_eol();
21612 37 }
21613
21614
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if(tempheader.zelda_version>=0x193)
21615 {
21616 dword section_id;
21617
21618 //section id
21619
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_mgetl(&section_id,f))
21620 {
21621 return qe_invalid;
21622 }
21623
21624 126 std::set<dword> seen_sections;
21625
21626
3/4
✓ Branch 0 taken 3042 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2916 times.
✓ Branch 3 taken 126 times.
3042 while(!pack_feof(f))
21627 {
21628
2/4
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2916 times.
✗ Branch 3 not taken.
2916 if (seen_sections.contains(section_id))
21629 return qe_invalid;
21630
1/2
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
2916 seen_sections.insert(section_id);
21631
21632
2/4
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2916 times.
✗ Branch 3 not taken.
2916 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21633 {
21634 if (retval == qe_cancel)
21635 continue;
21636 checkstatus(retval);
21637 }
21638
21639
24/25
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 126 times.
✓ Branch 5 taken 114 times.
✓ Branch 6 taken 126 times.
✓ Branch 7 taken 126 times.
✓ Branch 8 taken 126 times.
✓ Branch 9 taken 126 times.
✓ Branch 10 taken 126 times.
✓ Branch 11 taken 126 times.
✓ Branch 12 taken 114 times.
✓ Branch 13 taken 114 times.
✓ Branch 14 taken 126 times.
✓ Branch 15 taken 126 times.
✓ Branch 16 taken 114 times.
✓ Branch 17 taken 114 times.
✓ Branch 18 taken 114 times.
✓ Branch 19 taken 114 times.
✓ Branch 20 taken 126 times.
✓ Branch 21 taken 126 times.
✓ Branch 22 taken 114 times.
✓ Branch 23 taken 114 times.
✗ Branch 24 not taken.
2916 switch(section_id)
21640 {
21641 case ID_RULES:
21642
21643 //rules
21644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21645 {
21646 box_out("found.");
21647 box_eol();
21648 catchup=false;
21649 }
21650
21651
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Rules...");
21652
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readrules(f, &tempheader);
21653
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21654
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21655
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21656 126 break;
21657
21658 case ID_STRINGS:
21659
21660 //strings
21661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21662 {
21663 box_out("found.");
21664 box_eol();
21665 catchup=false;
21666 }
21667
21668
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Strings...");
21669
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readstrings(f, &tempheader);
21670
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21671
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21672
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21673 126 break;
21674
21675 case ID_MISC:
21676
21677 //misc data
21678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21679 {
21680 box_out("found.");
21681 box_eol();
21682 catchup=false;
21683 }
21684
21685
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Misc. Data...");
21686
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readmisc(f, &tempheader, Misc);
21687
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21688
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21689
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21690 126 break;
21691
21692 case ID_TILES:
21693
21694 //tiles
21695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21696 {
21697 box_out("found.");
21698 box_eol();
21699 catchup=false;
21700 }
21701
21702
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Tiles...");
21703
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21704
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21705
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21706
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21707 126 break;
21708
21709 case ID_COMBOS:
21710
21711 //combos
21712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21713 {
21714 box_out("found.");
21715 box_eol();
21716 catchup=false;
21717 }
21718
21719
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Combos...");
21720
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21721 126 combosread=true;
21722
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21723
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21724
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21725 126 break;
21726
21727 case ID_COMBOALIASES:
21728
21729 //combo aliases
21730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21731 {
21732 box_out("found.");
21733 box_eol();
21734 catchup=false;
21735 }
21736
21737
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Combo Aliases...");
21738
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21739
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21740
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21741
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21742 114 break;
21743
21744 case ID_CSETS:
21745
21746 //color data
21747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21748 {
21749 box_out("found.");
21750 box_eol();
21751 catchup=false;
21752 }
21753
21754
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Color Data...");
21755
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21756
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21757
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21758
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21759 126 break;
21760
21761 case ID_MAPS:
21762
21763 //maps
21764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21765 {
21766 box_out("found.");
21767 box_eol();
21768 catchup=false;
21769 }
21770
21771
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Maps...");
21772
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readmaps(f, &tempheader);
21773 126 mapsread=true;
21774
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21775
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21776
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21777 126 break;
21778
21779 case ID_DMAPS:
21780
21781 //dmaps
21782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21783 {
21784 box_out("found.");
21785 box_eol();
21786 catchup=false;
21787 }
21788
21789
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading DMaps...");
21790
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21791
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21792
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21793
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21794 126 break;
21795
21796 case ID_DOORS:
21797
21798 //door combo sets
21799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21800 {
21801 box_out("found.");
21802 box_eol();
21803 catchup=false;
21804 }
21805
21806
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Doors...");
21807
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readdoorcombosets(f, &tempheader);
21808
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21809
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21810
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21811 126 break;
21812
21813 case ID_ITEMS:
21814
21815 //items
21816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21817 {
21818 box_out("found.");
21819 box_eol();
21820 catchup=false;
21821 }
21822
21823
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Items...");
21824
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21825
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21826
21827
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21828
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21829 126 break;
21830
21831 case ID_WEAPONS:
21832
21833 //weapons
21834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21835 {
21836 box_out("found.");
21837 box_eol();
21838 catchup=false;
21839 }
21840
21841
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Weapons...");
21842
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readweapons(f, &tempheader);
21843
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21844
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21845
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21846 126 break;
21847
21848 case ID_COLORS:
21849
21850 //misc. colors
21851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21852 {
21853 box_out("found.");
21854 box_eol();
21855 catchup=false;
21856 }
21857
21858
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Misc. Colors...");
21859
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readmisccolors(f, &tempheader, Misc);
21860
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21861
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21862
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21863 114 break;
21864
21865 case ID_ICONS:
21866
21867 //game icons
21868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21869 {
21870 box_out("found.");
21871 box_eol();
21872 catchup=false;
21873 }
21874
21875
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Game Icons...");
21876
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readgameicons(f, &tempheader, Misc);
21877
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21878
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21879
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21880 114 break;
21881
21882 case ID_INITDATA:
21883
21884 //initialization data
21885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21886 {
21887 box_out("found.");
21888 box_eol();
21889 catchup=false;
21890 }
21891
21892
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Init. Data...");
21893
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readinitdata(f, &tempheader);
21894
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21895
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21896
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21897
21898
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if(!get_bit(skip_flags, skip_subscreens))
21899 {
21900
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 99 times.
126 if(subscr_mode!=ssdtMAX) //not using custom subscreens
21901 {
21902
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21903
21904
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21905 {
21906 13824 int32_t type=DMaps[i].type&dmfTYPE;
21907
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21908 13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21909 13824 }
21910 27 }
21911 126 }
21912
21913
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if(!get_bit(skip_flags, skip_sfx))
21914 {
21915 126 setupsfx();
21916 126 }
21917
21918
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 if(!get_bit(skip_flags, skip_itemdropsets))
21919 {
21920
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 init_item_drop_sets();
21921 126 }
21922
21923
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if(!get_bit(skip_flags, skip_favorites))
21924 {
21925 126 init_favorites();
21926 126 }
21927
21928 126 break;
21929
21930 case ID_GUYS:
21931
21932 //guys
21933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
21934 {
21935 box_out("found.");
21936 box_eol();
21937 catchup=false;
21938 }
21939
21940
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Custom Guy Data...");
21941
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readguys(f, &tempheader);
21942
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
21943
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
21944
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
21945 126 break;
21946
21947 case ID_HEROSPRITES:
21948
21949 //player sprites
21950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21951 {
21952 box_out("found.");
21953 box_eol();
21954 catchup=false;
21955 }
21956
21957
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Custom Player Sprite Data...");
21958
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readherosprites(f, &tempheader);
21959
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21960
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21961
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21962 114 break;
21963
21964 case ID_SUBSCREEN:
21965
21966 //custom subscreens
21967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21968 {
21969 box_out("found.");
21970 box_eol();
21971 catchup=false;
21972 }
21973
21974
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Custom Subscreen Data...");
21975
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readsubscreens(f);
21976
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21977
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21978
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21979 114 break;
21980
21981 case ID_FFSCRIPT:
21982
21983 //Freeform combo scripts
21984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
21985 {
21986 box_out("found.");
21987 box_eol();
21988 catchup=false;
21989 }
21990
21991
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading FF Script Data...");
21992
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readffscript(f, &tempheader);
21993
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
21994
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
21995
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
21996 114 break;
21997
21998 case ID_SFX:
21999
22000 //SFX data
22001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
22002 {
22003 box_out("found.");
22004 box_eol();
22005 catchup=false;
22006 }
22007
22008
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading SFX Data...");
22009
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readsfx(f, &tempheader);
22010
1/9
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
22011
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
22012
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
22013 114 break;
22014
22015 case ID_MIDIS:
22016
22017 //midis
22018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
22019 {
22020 box_out("found.");
22021 box_eol();
22022 catchup=false;
22023 }
22024
22025
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Tunes...");
22026
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readtunes(f, &tempheader, tunes);
22027
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
22028
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
22029
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
22030 126 break;
22031
22032 case ID_CHEATS:
22033
22034 //cheat codes
22035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(catchup)
22036 {
22037 box_out("found.");
22038 box_eol();
22039 catchup=false;
22040 }
22041
22042
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("Reading Cheat Codes...");
22043
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 ret=readcheatcodes(f, &tempheader);
22044
1/9
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
126 checkstatus(ret);
22045
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_out("okay.");
22046
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 box_eol();
22047 126 break;
22048
22049 case ID_ITEMDROPSETS:
22050
22051 //item drop sets
22052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
22053 {
22054 box_out("found.");
22055 box_eol();
22056 catchup=false;
22057 }
22058
22059
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Item Drop Sets...");
22060
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
22061
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
22062
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
22063
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
22064 114 break;
22065
22066 case ID_FAVORITES:
22067
22068 //favorite combos and combo aliases
22069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(catchup)
22070 {
22071 box_out("found.");
22072 box_eol();
22073 catchup=false;
22074 }
22075
22076
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("Reading Favorite Combos...");
22077
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
22078
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
114 checkstatus(ret);
22079
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_out("okay.");
22080
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 box_eol();
22081 114 break;
22082
22083 default:
22084 if(!catchup)
22085 {
22086 box_out("Bad token! Searching...");
22087 box_eol();
22088 }
22089
22090 catchup=true;
22091 break;
22092 }
22093
22094
22095
1/2
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
2916 if(catchup)
22096 {
22097 //section id
22098 section_id=(section_id<<8);
22099
22100 if(!p_getc(&tempbyte,f))
22101 {
22102 return qe_invalid;
22103 }
22104
22105 section_id+=tempbyte;
22106 }
22107
22108 else
22109 {
22110 //section id
22111
3/4
✓ Branch 0 taken 2916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2790 times.
✓ Branch 3 taken 126 times.
2916 if(!pack_feof(f))
22112 {
22113
2/4
✓ Branch 0 taken 2790 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2790 times.
✗ Branch 3 not taken.
2790 if(!p_mgetl(&section_id,f))
22114 {
22115 return qe_invalid;
22116 }
22117 2790 }
22118 }
22119 }
22120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 }
22121 else
22122 {
22123
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22124
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22125
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22126
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22127
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22128
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22129
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22130
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22131
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22132
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22133
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22134
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22135
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22136
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22137
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22138
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22139
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22140
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22141 };
22142
22143 4 legacy_skip_flags = skip_flags;
22144
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
208 for (auto& [desc, section_id, fn] : hardcoded_sections)
22145 {
22146
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 int section_enum = section_id_to_enum(section_id);
22147
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
68 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22148
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 if (skip)
22149 {
22150 // Nothing to read.
22151 if (section_id == ID_RULES)
22152 continue;
22153 if (section_id == ID_GUYS)
22154 continue;
22155
22156 // Haven't looked at how to skip these, because we don't need to currently: the only
22157 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22158 if (section_id == ID_MIDIS)
22159 continue;
22160 if (section_id == ID_CHEATS)
22161 continue;
22162 if (section_id == ID_INITDATA)
22163 continue;
22164 if (section_id == ID_HEROSPRITES)
22165 continue;
22166 if (section_id == ID_ITEMDROPSETS)
22167 continue;
22168 }
22169
22170 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22171 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22172 // read all the sections even if requested to skip some.
22173 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22174 // {
22175 // if (retval == qe_cancel)
22176 // continue;
22177 // checkstatus(retval);
22178 // }
22179
22180
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
22181
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
22182
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
22183
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
22184
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
22185 }
22186 4 legacy_skip_flags = nullptr;
22187
22188
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
22189 {
22190
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
22191
22192
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22193 {
22194 2048 int32_t type=DMaps[i].type&dmfTYPE;
22195
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22196 2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22197 2048 }
22198 4 }
22199
22200
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
22201
22202
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
22203 4 setupsfx();
22204
22205
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_favorites))
22206 4 init_favorites();
22207
22208
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
22209
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
22210
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
22211
22212 130 init_spritelists();
22213
22214 // check data
22215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(f)
22216 {
22217 130 pack_fclose(f);
22218 130 }
22219 130 clear_quest_tmpfile();
22220
22221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!oldquest)
22222 {
22223
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(exists(tmpfilename))
22224 {
22225 delete_file(tmpfilename);
22226 }
22227 130 }
22228
22229
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
130 if(fixffcs && combosread && mapsread)
22230 {
22231 for(int32_t i=0; i<map_count; i++)
22232 {
22233 for(int32_t j=0; j<MAPSCRS; j++)
22234 {
22235 for(int32_t m=0; m<32; m++)
22236 {
22237 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22238 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22239 }
22240 }
22241 }
22242 }
22243
22244
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
130 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22245 {
22246 29 set_qr(qr_CONTFULL_DEP, 0);
22247 29 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22248 29 zinit.cont_heart=100;
22249 29 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22250 29 }
22251
22252 130 box_out("Done.");
22253 130 box_eol();
22254 130 box_end(false);
22255
22256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!get_bit(skip_flags, skip_header))
22257 {
22258 130 memcpy(Header, &tempheader, sizeof(tempheader));
22259 130 }
22260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(!get_bit(skip_flags, skip_zinfo))
22261 {
22262 130 ZI.copyFrom(tempzi);
22263 130 }
22264
22265
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(get_bit(skip_flags, skip_maps))
22266 {
22267 map_count=old_map_count;
22268 }
22269
22270
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(get_bit(skip_flags, skip_rules))
22271 {
22272 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22273 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22274 unpack_qrs();
22275 }
22276
22277
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(get_bit(skip_flags, skip_midis))
22278 {
22279 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22280 }
22281
22282
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4 times.
130 if( FFCore.quest_format[vZelda] < 0x210 )
22283 {
22284 4 zprint2("\n[QUEST METADATA]\n");
22285
22286
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22287 {
22288 case 0x193:
22289 {
22290 zprint2("Last saved in version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22291 }
22292 case 0x192:
22293 {
22294 zprint2("Last saved in version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22295 }
22296 case 0x190:
22297 {
22298 4 zprint2("Last saved in version: 1.90");
22299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22300 4 else zprint2("\n");
22301 4 break;
22302 }
22303 case 0x188:
22304 {
22305 zprint2("Last saved in version: 1.88");
22306 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22307 else zprint2("\n");
22308 break;
22309 }
22310 case 0x187:
22311 {
22312 zprint2("Last saved in version: 1.87");
22313 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22314 else zprint2("\n");
22315 break;
22316 }
22317 case 0x186:
22318 {
22319 zprint2("Last saved in version: 1.86");
22320 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22321 else zprint2("\n");
22322 break;
22323 }
22324 case 0x185:
22325 {
22326 zprint2("Last saved in version: 1.85");
22327 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22328 else zprint2("\n");
22329 break;
22330 }
22331 case 0x184:
22332 {
22333 zprint2("Last saved in version: 1.84");
22334 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22335 else zprint2("\n");
22336 break;
22337 }
22338 case 0x183:
22339 {
22340 zprint2("Last saved in version: 1.83");
22341 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22342 else zprint2("\n");
22343 break;
22344 }
22345 case 0x182:
22346 {
22347 zprint2("Last saved in version: 1.82");
22348 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22349 else zprint2("\n");
22350 break;
22351 }
22352 case 0x181:
22353 {
22354 zprint2("Last saved in version: 1.81");
22355 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22356 else zprint2("\n");
22357 break;
22358 }
22359 case 0x180:
22360 {
22361 zprint2("Last saved in version: 1.80");
22362 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22363 else zprint2("\n");
22364 break;
22365 }
22366 default:
22367 {
22368 zprint2("Last saved in version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22369 }
22370 }
22371 4 }
22372
22373
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(loading_tileset_flags & TILESET_CLEARMAPS)
22374 {
22375 TheMaps.clear();
22376 TheMaps.resize(MAPSCRS*1);
22377 map_count = 1;
22378 map_autolayers.clear();
22379 map_autolayers.resize(6*1);
22380 for(size_t i = 0; i < MAPSCRS; ++i)
22381 {
22382 TheMaps[i].zero_memory();
22383 }
22384 }
22385
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(loading_tileset_flags & TILESET_CLEARHEADER)
22386 {
22387 memset(Header->password, 0, sizeof(Header->password));
22388 memset(Header->minver, 0, sizeof(Header->minver));
22389 memset(Header->title, 0, sizeof(Header->title));
22390 memset(Header->author, 0, sizeof(Header->author));
22391 memset(Header->version, 0, sizeof(Header->version));
22392 Header->use_keyfile = 0;
22393 Header->dirty_password = false;
22394 cvs_MD5Context ctx;
22395 cvs_MD5Init(&ctx);
22396 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22397 cvs_MD5Final(Header->pwd_hash, &ctx);
22398 }
22399
22400 130 return qe_OK;
22401
22402 invalid:
22403 box_out("error.");
22404 box_eol();
22405 box_end(true);
22406
22407 if(f)
22408 {
22409 pack_fclose(f);
22410 }
22411
22412 if(!oldquest)
22413 {
22414 if(exists(tmpfilename))
22415 {
22416 delete_file(tmpfilename);
22417 }
22418 }
22419
22420 return qe_invalid;
22421
22422 130 }
22423
22424 static bool _is_loading_quest;
22425
22426 bool is_loading_quest()
22427 {
22428 return _is_loading_quest;
22429 }
22430
22431 130 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22432 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22433 bool report, byte qst_num, dword tilesetflags)
22434 {
22435 130 loading_tileset_flags = tilesetflags;
22436 130 const char* basename = get_filename(filename);
22437 130 zapp_reporting_add_breadcrumb("load_quest", basename);
22438 130 zapp_reporting_set_tag("qst.filename", basename);
22439
22440 130 loading_qst_name = filename;
22441 130 loading_qst_num = qst_num;
22442 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22443 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22444
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if (!is_ci())
22445 loadquest_report = report;
22446
22447 130 _is_loading_quest = true;
22448 130 auto start = std::chrono::steady_clock::now();
22449 130 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22450 130 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22451 130 zprint2("Time to load qst: %d ms\n", load_ms);
22452 130 _is_loading_quest = false;
22453
22454
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 if(show_progress)
22455 {
22456 if(ret)
22457 {
22458 box_out("-- Error loading quest file! --");
22459 box_end(true);
22460 }
22461 else box_end(false);
22462 }
22463
22464 130 load_tmp_zi = NULL;
22465 130 loading_qst_name = NULL;
22466 130 loadquest_report = false;
22467 130 loading_qst_num = 0;
22468
22469 130 zapp_reporting_set_tag("qst.title", Header->title);
22470 130 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22471
22472 130 return ret;
22473 }
22474